File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed
Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches : [main]
7+
8+ jobs :
9+ test :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout
13+ uses : actions/checkout@v4
14+
15+ - name : Setup Bun
16+ uses : oven-sh/setup-bun@v2
17+ with :
18+ bun-version : latest
19+
20+ - name : Install dependencies
21+ run : bun install
22+
23+ - name : Run tests
24+ run : bun test
25+
26+ - name : Build
27+ run : bun run build
Original file line number Diff line number Diff line change @@ -219,4 +219,31 @@ describe("quiddity create", () => {
219219
220220 hook . unmount ( )
221221 } )
222+
223+ it ( "exposes derived functions that read latest state" , ( ) => {
224+ const useStore = createStore < {
225+ count : number
226+ inc : ( ) => void
227+ } > (
228+ ( set ) => ( {
229+ count : 2 ,
230+ inc : ( ) => set ( ( state ) => ( { count : state . count + 1 } ) ) ,
231+ } ) ,
232+ ( state ) => ( {
233+ multBy : ( n : number ) => state . count * n ,
234+ } )
235+ )
236+
237+ const hook = renderHook ( useStore )
238+
239+ expect ( hook . current . multBy ( 3 ) ) . toBe ( 6 )
240+
241+ act ( ( ) => {
242+ hook . current . inc ( )
243+ } )
244+
245+ expect ( hook . current . multBy ( 3 ) ) . toBe ( 9 )
246+
247+ hook . unmount ( )
248+ } )
222249} )
Original file line number Diff line number Diff line change 66 },
77 "version" : " 0.1.0" ,
88 "description" : " Local-first React state helpers with mutator-style updates." ,
9+ "license" : " MIT" ,
910 "main" : " ./dist/index.cjs" ,
1011 "module" : " ./dist/index.js" ,
1112 "types" : " ./dist/index.d.ts" ,
4243 },
4344 "files" : [
4445 " dist" ,
46+ " LICENSE" ,
4547 " README.md"
4648 ]
4749}
You can’t perform that action at this time.
0 commit comments