Skip to content

Commit

Permalink
chore(test): dev store method (#2873)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Dec 19, 2024
1 parent a9933f1 commit 7e463d1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/vanilla/storedev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {

describe('[DEV-ONLY] dev-only methods rev4', () => {
it('should get atom value', () => {
const store = createStore() as any
const store = createStore() as INTERNAL_DevStoreRev4 & INTERNAL_PrdStore
if (!('dev4_get_internal_weak_map' in store)) {
throw new Error('dev methods are not available')
}
Expand All @@ -19,7 +19,7 @@ describe('[DEV-ONLY] dev-only methods rev4', () => {
})

it('should restore atoms and its dependencies correctly', () => {
const store = createStore() as any
const store = createStore() as INTERNAL_DevStoreRev4 & INTERNAL_PrdStore
if (!('dev4_restore_atoms' in store)) {
throw new Error('dev methods are not available')
}
Expand All @@ -32,7 +32,7 @@ describe('[DEV-ONLY] dev-only methods rev4', () => {
})

it('should restore atoms and call store listeners correctly', () => {
const store = createStore() as any
const store = createStore() as INTERNAL_DevStoreRev4 & INTERNAL_PrdStore
if (!('dev4_restore_atoms' in store)) {
throw new Error('dev methods are not available')
}
Expand Down Expand Up @@ -96,4 +96,14 @@ describe('[DEV-ONLY] dev-only methods rev4', () => {
const result = store.dev4_get_mounted_atoms()
expect(Array.from(result)).toStrictEqual([])
})

it('should restore atoms with custom write function', () => {
const store = createStore() as INTERNAL_DevStoreRev4 & INTERNAL_PrdStore
if (!('dev4_restore_atoms' in store)) {
throw new Error('dev methods are not available')
}
const countAtom = atom(0, () => {})
store.dev4_restore_atoms([[countAtom, 1]])
expect(store.get(countAtom)).toBe(1)
})
})

0 comments on commit 7e463d1

Please sign in to comment.