We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf37b85 commit f0f082bCopy full SHA for f0f082b
packages/store/tests/batch.test.ts
@@ -0,0 +1,20 @@
1
+import { describe, expect, test } from 'vitest'
2
+import { Store } from '../src/store'
3
+import { batch } from '../src'
4
+
5
+describe('batch', () => {
6
+ test('updates store immediately', () => {
7
+ const store = new Store({ hello: 100, world: 200 })
8
+ batch(() => {
9
+ store.setState((state) => ({ ...state, hello: state.hello + 1 }))
10
+ expect(store.state.hello).toBe(101)
11
+ expect(store.state.world).toBe(200)
12
+ store.setState((state) => ({ ...state, world: state.world + 1 }))
13
14
+ expect(store.state.world).toBe(201)
15
+ })
16
17
18
19
20
+})
0 commit comments