From cdf01cd07f570995cf771955ac37245e2d459714 Mon Sep 17 00:00:00 2001 From: gonzaloriestra <14979109+gonzaloriestra@users.noreply.github.com> Date: Sun, 23 Aug 2026 00:18:24 +0000 Subject: [PATCH 1/2] [Tests] Add unit tests for deprecations store --- .../node/context/deprecations-store.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/cli-kit/src/private/node/context/deprecations-store.test.ts diff --git a/packages/cli-kit/src/private/node/context/deprecations-store.test.ts b/packages/cli-kit/src/private/node/context/deprecations-store.test.ts new file mode 100644 index 00000000000..7a094167c22 --- /dev/null +++ b/packages/cli-kit/src/private/node/context/deprecations-store.test.ts @@ -0,0 +1,48 @@ +import {getNextDeprecationDate, setNextDeprecationDate} from './deprecations-store.js' +import {describe, test, expect} from 'vitest' + +describe('deprecations-store', () => { + test('getNextDeprecationDate returns undefined by default', () => { + expect(getNextDeprecationDate()).toBeUndefined() + }) + + test('setNextDeprecationDate does not update store when given empty dates list', () => { + setNextDeprecationDate([]) + expect(getNextDeprecationDate()).toBeUndefined() + }) + + test('setNextDeprecationDate does not update store when dates are in the past', () => { + const pastDate = new Date(Date.now() - 100000) + setNextDeprecationDate([pastDate]) + expect(getNextDeprecationDate()).toBeUndefined() + }) + + test('setNextDeprecationDate sets earliest future deprecation date', () => { + const futureDate1 = new Date(Date.now() + 100000) + const futureDate2 = new Date(Date.now() + 200000) + + setNextDeprecationDate([futureDate2, futureDate1]) + + expect(getNextDeprecationDate()).toEqual(futureDate1) + }) + + test('setNextDeprecationDate updates store if a newer date is earlier than existing nextDeprecationDate', () => { + const initialFutureDate = new Date(Date.now() + 100000) + setNextDeprecationDate([initialFutureDate]) + + const earlierFutureDate = new Date(Date.now() + 50000) + setNextDeprecationDate([earlierFutureDate]) + + expect(getNextDeprecationDate()).toEqual(earlierFutureDate) + }) + + test('setNextDeprecationDate keeps existing date if new future dates are later', () => { + const initialFutureDate = new Date(Date.now() + 50000) + setNextDeprecationDate([initialFutureDate]) + + const laterFutureDate = new Date(Date.now() + 300000) + setNextDeprecationDate([laterFutureDate]) + + expect(getNextDeprecationDate()).toEqual(initialFutureDate) + }) +}) From 0d79312e9e3648c10d60ba4a519299c57ee75f9d Mon Sep 17 00:00:00 2001 From: gonzaloriestra <14979109+gonzaloriestra@users.noreply.github.com> Date: Sun, 23 Aug 2026 00:34:14 +0000 Subject: [PATCH 2/2] [Tests] Add unit tests for deprecations store --- .../private/node/context/deprecations-store.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli-kit/src/private/node/context/deprecations-store.test.ts b/packages/cli-kit/src/private/node/context/deprecations-store.test.ts index 7a094167c22..c300ec6453c 100644 --- a/packages/cli-kit/src/private/node/context/deprecations-store.test.ts +++ b/packages/cli-kit/src/private/node/context/deprecations-store.test.ts @@ -18,8 +18,8 @@ describe('deprecations-store', () => { }) test('setNextDeprecationDate sets earliest future deprecation date', () => { - const futureDate1 = new Date(Date.now() + 100000) - const futureDate2 = new Date(Date.now() + 200000) + const futureDate1 = new Date(Date.now() + 500000) + const futureDate2 = new Date(Date.now() + 600000) setNextDeprecationDate([futureDate2, futureDate1]) @@ -27,20 +27,20 @@ describe('deprecations-store', () => { }) test('setNextDeprecationDate updates store if a newer date is earlier than existing nextDeprecationDate', () => { - const initialFutureDate = new Date(Date.now() + 100000) + const initialFutureDate = new Date(Date.now() + 400000) setNextDeprecationDate([initialFutureDate]) - const earlierFutureDate = new Date(Date.now() + 50000) + const earlierFutureDate = new Date(Date.now() + 300000) setNextDeprecationDate([earlierFutureDate]) expect(getNextDeprecationDate()).toEqual(earlierFutureDate) }) test('setNextDeprecationDate keeps existing date if new future dates are later', () => { - const initialFutureDate = new Date(Date.now() + 50000) + const initialFutureDate = new Date(Date.now() + 100000) setNextDeprecationDate([initialFutureDate]) - const laterFutureDate = new Date(Date.now() + 300000) + const laterFutureDate = new Date(Date.now() + 200000) setNextDeprecationDate([laterFutureDate]) expect(getNextDeprecationDate()).toEqual(initialFutureDate)