|
| 1 | +import { afterEach, describe, expect, jest, test } from '@jest/globals' |
| 2 | + |
| 3 | +import { |
| 4 | + isKeysOnlyModeDate, |
| 5 | + SPECIAL_CURRENCY_INFO |
| 6 | +} from '../../constants/WalletAndCurrencyConstants' |
| 7 | + |
| 8 | +const DEPRECATION_MS = new Date('2026-07-09T00:00:00.000Z').getTime() |
| 9 | + |
| 10 | +describe('isKeysOnlyModeDate', function () { |
| 11 | + afterEach(() => { |
| 12 | + jest.restoreAllMocks() |
| 13 | + }) |
| 14 | + |
| 15 | + const date = new Date('2026-07-09T00:00:00.000Z') |
| 16 | + |
| 17 | + test('returns false before the date', function () { |
| 18 | + jest.spyOn(Date, 'now').mockReturnValue(DEPRECATION_MS - 1) |
| 19 | + expect(isKeysOnlyModeDate(date)).toBe(false) |
| 20 | + }) |
| 21 | + |
| 22 | + test('returns true exactly on the date', function () { |
| 23 | + jest.spyOn(Date, 'now').mockReturnValue(DEPRECATION_MS) |
| 24 | + expect(isKeysOnlyModeDate(date)).toBe(true) |
| 25 | + }) |
| 26 | + |
| 27 | + test('returns true after the date', function () { |
| 28 | + jest.spyOn(Date, 'now').mockReturnValue(DEPRECATION_MS + 86400000) |
| 29 | + expect(isKeysOnlyModeDate(date)).toBe(true) |
| 30 | + }) |
| 31 | +}) |
| 32 | + |
| 33 | +describe('botanix keysOnlyMode', function () { |
| 34 | + afterEach(() => { |
| 35 | + jest.restoreAllMocks() |
| 36 | + }) |
| 37 | + |
| 38 | + // The flag is a getter so it re-evaluates the date on each read, rather than |
| 39 | + // freezing the value at module load. |
| 40 | + test('re-evaluates the date on each read', function () { |
| 41 | + const nowSpy = jest.spyOn(Date, 'now') |
| 42 | + |
| 43 | + nowSpy.mockReturnValue(DEPRECATION_MS - 1) |
| 44 | + expect(SPECIAL_CURRENCY_INFO.botanix.keysOnlyMode).toBe(false) |
| 45 | + |
| 46 | + nowSpy.mockReturnValue(DEPRECATION_MS) |
| 47 | + expect(SPECIAL_CURRENCY_INFO.botanix.keysOnlyMode).toBe(true) |
| 48 | + }) |
| 49 | +}) |
0 commit comments