@tldraw/state 3.16.0-next.f9f54ec051f3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { vi } from 'vitest'
1
2
  import { atom } from '../Atom'
2
3
  import { react, reactor } from '../EffectScheduler'
3
4
  import { advanceGlobalEpoch, transact } from '../transactions'
@@ -25,7 +26,7 @@ describe('reactors', () => {
25
26
  }
26
27
  })
27
28
  expect(() => r.start()).toThrowErrorMatchingInlineSnapshot(
28
- `"Reaction update depth limit exceeded"`
29
+ `[Error: Reaction update depth limit exceeded]`
29
30
  )
30
31
  })
31
32
 
@@ -33,7 +34,7 @@ describe('reactors', () => {
33
34
  const atomA = atom('', 1)
34
35
  const atomB = atom('', 1)
35
36
 
36
- const react = jest.fn(() => {
37
+ const react = vi.fn(() => {
37
38
  atomA.get()
38
39
  atomB.get()
39
40
  })
@@ -52,7 +53,7 @@ describe('reactors', () => {
52
53
 
53
54
  it('will not react if stopped', () => {
54
55
  const a = atom('', 1)
55
- const react = jest.fn(() => {
56
+ const react = vi.fn(() => {
56
57
  a.get()
57
58
  })
58
59
  const r = reactor('', react)
@@ -64,7 +65,7 @@ describe('reactors', () => {
64
65
 
65
66
  it('will not react if the parents have not changed', () => {
66
67
  const a = atom('', 1)
67
- const react = jest
68
+ const react = vi
68
69
  .fn(() => {
69
70
  a.get()
70
71
  })
@@ -84,7 +85,7 @@ describe('stopping', () => {
84
85
  it('works', () => {
85
86
  const a = atom('', 1)
86
87
 
87
- const rfn = jest.fn(() => {
88
+ const rfn = vi.fn(() => {
88
89
  a.get()
89
90
  })
90
91
  const r = reactor('', rfn)
@@ -119,7 +120,7 @@ describe('stopping', () => {
119
120
  test('.start() by default does not trigger a reaction if nothing has changed', () => {
120
121
  const a = atom('', 1)
121
122
 
122
- const rfn = jest.fn(() => {
123
+ const rfn = vi.fn(() => {
123
124
  a.get()
124
125
  })
125
126
 
@@ -138,7 +139,7 @@ test('.start() by default does not trigger a reaction if nothing has changed', (
138
139
  test('.start({force: true}) will trigger a reaction even if nothing has changed', () => {
139
140
  const a = atom('', 1)
140
141
 
141
- const rfn = jest.fn(() => {
142
+ const rfn = vi.fn(() => {
142
143
  a.get()
143
144
  })
144
145
 
@@ -1,4 +1,5 @@
1
1
  import { promiseWithResolve, sleep } from '@tldraw/utils'
2
+ import { vi } from 'vitest'
2
3
  import { atom } from '../Atom'
3
4
  import { computed } from '../Computed'
4
5
  import { react } from '../EffectScheduler'
@@ -222,7 +223,7 @@ describe('setting atoms during a reaction', () => {
222
223
  react('', () => {
223
224
  a.set(a.get() + 1)
224
225
  })
225
- }).toThrowErrorMatchingInlineSnapshot(`"Reaction update depth limit exceeded"`)
226
+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Reaction update depth limit exceeded]`)
226
227
  })
227
228
 
228
229
  it('should work with a transaction running', () => {
@@ -360,9 +361,9 @@ it('should defer all side effects until the end of the outer transaction', () =>
360
361
  const b = atom('', 0)
361
362
  const c = atom('', 0)
362
363
 
363
- const aChanged = jest.fn()
364
- const bChanged = jest.fn()
365
- const cChanged = jest.fn()
364
+ const aChanged = vi.fn()
365
+ const bChanged = vi.fn()
366
+ const cChanged = vi.fn()
366
367
 
367
368
  react('', () => {
368
369
  a.get()
@@ -442,7 +443,7 @@ describe('asyncTransaction', () => {
442
443
  a.set(1)
443
444
  })
444
445
 
445
- expect(txp).rejects.toMatchInlineSnapshot(
446
+ await expect(txp).rejects.toMatchInlineSnapshot(
446
447
  `[Error: deferAsyncEffects cannot be called during a sync transaction]`
447
448
  )
448
449
  })
@@ -536,7 +537,7 @@ describe('async tests generated by claude', () => {
536
537
  it('should defer effects until async transaction commits', async () => {
537
538
  const a = atom('', 0)
538
539
  const b = atom('', 0)
539
- const effectCalls = jest.fn()
540
+ const effectCalls = vi.fn()
540
541
 
541
542
  react('', () => {
542
543
  a.get()