-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix issues with Solid store tests
- Loading branch information
1 parent
6e5156d
commit 2baec1f
Showing
3 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { expectTypeOf, test } from 'vitest' | ||
import { Derived, Store, useStore } from '../src' | ||
import type { Accessor } from 'solid-js' | ||
|
||
test('useStore works with derived state', () => { | ||
const store = new Store(12) | ||
const derived = new Derived({ | ||
deps: [store], | ||
fn: () => { | ||
return { val: store.state * 2 } | ||
}, | ||
}) | ||
|
||
const val = useStore(derived, (state) => { | ||
expectTypeOf(state).toMatchTypeOf<{ val: number }>() | ||
return state.val | ||
}) | ||
|
||
expectTypeOf(val).toMatchTypeOf<Accessor<number>>() | ||
}) |