@tldraw/store 3.16.0-next.282b7be564ae → 3.16.0-next.6611943ca24a
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.
- package/dist-cjs/index.js +1 -1
- package/dist-esm/index.mjs +1 -1
- package/package.json +10 -18
- package/src/lib/test/AtomMap.test.ts +2 -1
- package/src/lib/test/dependsOn.test.ts +2 -2
- package/src/lib/test/recordStore.test.ts +40 -37
- package/src/lib/test/sortMigrations.test.ts +4 -4
- package/src/lib/test/validateMigrations.test.ts +8 -8
package/dist-cjs/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var import_StoreSchema = require("./lib/StoreSchema");
|
|
|
55
55
|
var import_StoreSideEffects = require("./lib/StoreSideEffects");
|
|
56
56
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
57
57
|
"@tldraw/store",
|
|
58
|
-
"3.16.0-next.
|
|
58
|
+
"3.16.0-next.6611943ca24a",
|
|
59
59
|
"cjs"
|
|
60
60
|
);
|
|
61
61
|
//# sourceMappingURL=index.js.map
|
package/dist-esm/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/store",
|
|
3
3
|
"description": "tldraw infinite canvas SDK (store).",
|
|
4
|
-
"version": "3.16.0-next.
|
|
4
|
+
"version": "3.16.0-next.6611943ca24a",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -32,19 +32,20 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"test-ci": "
|
|
36
|
-
"test": "yarn run -T
|
|
37
|
-
"test-coverage": "
|
|
35
|
+
"test-ci": "yarn run -T vitest run --passWithNoTests",
|
|
36
|
+
"test": "yarn run -T vitest --passWithNoTests",
|
|
37
|
+
"test-coverage": "yarn run -T vitest run --coverage --passWithNoTests",
|
|
38
38
|
"build": "yarn run -T tsx ../../internal/scripts/build-package.ts",
|
|
39
39
|
"build-api": "yarn run -T tsx ../../internal/scripts/build-api.ts",
|
|
40
40
|
"prepack": "yarn run -T tsx ../../internal/scripts/prepack.ts",
|
|
41
41
|
"postpack": "../../internal/scripts/postpack.sh",
|
|
42
42
|
"pack-tarball": "yarn pack",
|
|
43
|
-
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
|
|
43
|
+
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts",
|
|
44
|
+
"context": "yarn run -T tsx ../../internal/scripts/context.ts"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@tldraw/state": "3.16.0-next.
|
|
47
|
-
"@tldraw/utils": "3.16.0-next.
|
|
47
|
+
"@tldraw/state": "3.16.0-next.6611943ca24a",
|
|
48
|
+
"@tldraw/utils": "3.16.0-next.6611943ca24a"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"react": "^18.2.0 || ^19.0.0"
|
|
@@ -52,17 +53,8 @@
|
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@peculiar/webcrypto": "^1.5.0",
|
|
54
55
|
"lazyrepo": "0.0.0-alpha.27",
|
|
55
|
-
"raf": "^3.4.1"
|
|
56
|
-
|
|
57
|
-
"jest": {
|
|
58
|
-
"preset": "../../internal/config/jest/node/jest-preset.js",
|
|
59
|
-
"setupFiles": [
|
|
60
|
-
"./setupTests.js",
|
|
61
|
-
"raf/polyfill"
|
|
62
|
-
],
|
|
63
|
-
"moduleNameMapper": {
|
|
64
|
-
"^~(.*)": "<rootDir>/src/$1"
|
|
65
|
-
}
|
|
56
|
+
"raf": "^3.4.1",
|
|
57
|
+
"vitest": "^3.2.4"
|
|
66
58
|
},
|
|
67
59
|
"module": "dist-esm/index.mjs",
|
|
68
60
|
"source": "src/index.ts",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { react, transaction } from '@tldraw/state'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { AtomMap } from '../AtomMap'
|
|
3
4
|
|
|
4
5
|
describe('AtomMap', () => {
|
|
@@ -11,7 +12,7 @@ describe('AtomMap', () => {
|
|
|
11
12
|
})
|
|
12
13
|
|
|
13
14
|
function testReactor(name: string, fn: () => any) {
|
|
14
|
-
const cb =
|
|
15
|
+
const cb = vi.fn(fn)
|
|
15
16
|
const cleanup = react(name, cb)
|
|
16
17
|
cleanupFns.push(() => cleanup())
|
|
17
18
|
return cb
|
|
@@ -26,7 +26,7 @@ describe('dependsOn', () => {
|
|
|
26
26
|
}
|
|
27
27
|
)
|
|
28
28
|
}).toThrowErrorMatchingInlineSnapshot(
|
|
29
|
-
`
|
|
29
|
+
`[Error: Migration 'foo/1' depends on missing migration 'bar/1']`
|
|
30
30
|
)
|
|
31
31
|
})
|
|
32
32
|
|
|
@@ -108,7 +108,7 @@ describe('standalone dependsOn', () => {
|
|
|
108
108
|
}
|
|
109
109
|
)
|
|
110
110
|
}).toThrowErrorMatchingInlineSnapshot(
|
|
111
|
-
`
|
|
111
|
+
`[Error: Migration 'foo/1' depends on missing migration 'bar/1']`
|
|
112
112
|
)
|
|
113
113
|
})
|
|
114
114
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Computed, react, RESET_VALUE, transact } from '@tldraw/state'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { BaseRecord, RecordId } from '../BaseRecord'
|
|
3
4
|
import { createMigrationSequence } from '../migrate'
|
|
4
5
|
import { RecordsDiff, reverseRecordsDiff } from '../RecordsDiff'
|
|
@@ -206,7 +207,7 @@ describe('Store', () => {
|
|
|
206
207
|
|
|
207
208
|
it('allows adding onAfterChange callbacks that see the final state of the world', () => {
|
|
208
209
|
/* ADDING */
|
|
209
|
-
const onAfterCreate =
|
|
210
|
+
const onAfterCreate = vi.fn((current) => {
|
|
210
211
|
expect(current).toEqual(
|
|
211
212
|
Author.create({ name: 'J.R.R Tolkein', id: Author.createId('tolkein') })
|
|
212
213
|
)
|
|
@@ -218,7 +219,7 @@ describe('Store', () => {
|
|
|
218
219
|
expect(onAfterCreate).toHaveBeenCalledTimes(1)
|
|
219
220
|
|
|
220
221
|
/* UPDATING */
|
|
221
|
-
const onAfterChange =
|
|
222
|
+
const onAfterChange = vi.fn((prev, current) => {
|
|
222
223
|
expect(prev.name).toBe('J.R.R Tolkein')
|
|
223
224
|
expect(current.name).toBe('Butch Cassidy')
|
|
224
225
|
|
|
@@ -231,7 +232,7 @@ describe('Store', () => {
|
|
|
231
232
|
expect(onAfterChange).toHaveBeenCalledTimes(1)
|
|
232
233
|
|
|
233
234
|
/* REMOVING */
|
|
234
|
-
const onAfterDelete =
|
|
235
|
+
const onAfterDelete = vi.fn((prev) => {
|
|
235
236
|
if (prev.typeName === 'author') {
|
|
236
237
|
expect(prev.name).toBe('Butch Cassidy')
|
|
237
238
|
}
|
|
@@ -309,7 +310,7 @@ describe('Store', () => {
|
|
|
309
310
|
})
|
|
310
311
|
|
|
311
312
|
it('supports listening for changes to the whole store', async () => {
|
|
312
|
-
const listener =
|
|
313
|
+
const listener = vi.fn()
|
|
313
314
|
store.listen(listener)
|
|
314
315
|
|
|
315
316
|
transact(() => {
|
|
@@ -336,7 +337,7 @@ describe('Store', () => {
|
|
|
336
337
|
|
|
337
338
|
await new Promise((resolve) => requestAnimationFrame(resolve))
|
|
338
339
|
expect(listener).toHaveBeenCalledTimes(1)
|
|
339
|
-
expect(listener.mock.lastCall[0]).toMatchInlineSnapshot(`
|
|
340
|
+
expect(listener.mock.lastCall?.[0]).toMatchInlineSnapshot(`
|
|
340
341
|
{
|
|
341
342
|
"changes": {
|
|
342
343
|
"added": {
|
|
@@ -391,7 +392,7 @@ describe('Store', () => {
|
|
|
391
392
|
await new Promise((resolve) => requestAnimationFrame(resolve))
|
|
392
393
|
expect(listener).toHaveBeenCalledTimes(2)
|
|
393
394
|
|
|
394
|
-
expect(listener.mock.lastCall[0]).toMatchInlineSnapshot(`
|
|
395
|
+
expect(listener.mock.lastCall?.[0]).toMatchInlineSnapshot(`
|
|
395
396
|
{
|
|
396
397
|
"changes": {
|
|
397
398
|
"added": {},
|
|
@@ -444,7 +445,7 @@ describe('Store', () => {
|
|
|
444
445
|
await new Promise((resolve) => requestAnimationFrame(resolve))
|
|
445
446
|
expect(listener).toHaveBeenCalledTimes(3)
|
|
446
447
|
|
|
447
|
-
expect(listener.mock.lastCall[0]).toMatchInlineSnapshot(`
|
|
448
|
+
expect(listener.mock.lastCall?.[0]).toMatchInlineSnapshot(`
|
|
448
449
|
{
|
|
449
450
|
"changes": {
|
|
450
451
|
"added": {},
|
|
@@ -480,7 +481,7 @@ describe('Store', () => {
|
|
|
480
481
|
})
|
|
481
482
|
|
|
482
483
|
it('supports filtering history by scope', () => {
|
|
483
|
-
const listener =
|
|
484
|
+
const listener = vi.fn()
|
|
484
485
|
store.listen(listener, {
|
|
485
486
|
scope: 'session',
|
|
486
487
|
})
|
|
@@ -521,7 +522,7 @@ describe('Store', () => {
|
|
|
521
522
|
})
|
|
522
523
|
|
|
523
524
|
it('supports filtering history by scope (2)', () => {
|
|
524
|
-
const listener =
|
|
525
|
+
const listener = vi.fn()
|
|
525
526
|
store.listen(listener, {
|
|
526
527
|
scope: 'document',
|
|
527
528
|
})
|
|
@@ -550,7 +551,7 @@ describe('Store', () => {
|
|
|
550
551
|
})
|
|
551
552
|
|
|
552
553
|
it('supports filtering history by source', () => {
|
|
553
|
-
const listener =
|
|
554
|
+
const listener = vi.fn()
|
|
554
555
|
store.listen(listener, {
|
|
555
556
|
source: 'remote',
|
|
556
557
|
})
|
|
@@ -600,7 +601,7 @@ describe('Store', () => {
|
|
|
600
601
|
})
|
|
601
602
|
|
|
602
603
|
it('supports filtering history by source (user)', () => {
|
|
603
|
-
const listener =
|
|
604
|
+
const listener = vi.fn()
|
|
604
605
|
store.listen(listener, {
|
|
605
606
|
source: 'user',
|
|
606
607
|
})
|
|
@@ -658,7 +659,7 @@ describe('Store', () => {
|
|
|
658
659
|
// @ts-expect-error
|
|
659
660
|
globalThis.__FORCE_RAF_IN_TESTS__ = true
|
|
660
661
|
store.put([Author.create({ name: 'J.R.R Tolkein', id: Author.createId('tolkein') })])
|
|
661
|
-
const firstListener =
|
|
662
|
+
const firstListener = vi.fn()
|
|
662
663
|
store.listen(firstListener)
|
|
663
664
|
expect(firstListener).toHaveBeenCalledTimes(0)
|
|
664
665
|
|
|
@@ -666,7 +667,7 @@ describe('Store', () => {
|
|
|
666
667
|
|
|
667
668
|
expect(firstListener).toHaveBeenCalledTimes(0)
|
|
668
669
|
|
|
669
|
-
const secondListener =
|
|
670
|
+
const secondListener = vi.fn()
|
|
670
671
|
|
|
671
672
|
store.listen(secondListener)
|
|
672
673
|
|
|
@@ -707,7 +708,7 @@ describe('Store', () => {
|
|
|
707
708
|
const id = Author.createId('tolkein')
|
|
708
709
|
store.put([Author.create({ name: 'J.R.R Tolkein', id })])
|
|
709
710
|
|
|
710
|
-
const listener =
|
|
711
|
+
const listener = vi.fn()
|
|
711
712
|
store.listen(listener)
|
|
712
713
|
|
|
713
714
|
// Return the exact same value that came in
|
|
@@ -717,7 +718,7 @@ describe('Store', () => {
|
|
|
717
718
|
})
|
|
718
719
|
|
|
719
720
|
it('tells listeners the source of the changes so they can decide if they want to run or not', async () => {
|
|
720
|
-
const listener =
|
|
721
|
+
const listener = vi.fn()
|
|
721
722
|
store.listen(listener)
|
|
722
723
|
|
|
723
724
|
store.put([Author.create({ name: 'Jimmy Beans', id: Author.createId('jimmy') })])
|
|
@@ -824,7 +825,7 @@ describe('snapshots', () => {
|
|
|
824
825
|
expect(() => {
|
|
825
826
|
// @ts-expect-error
|
|
826
827
|
store2.loadStoreSnapshot(snapshot1)
|
|
827
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
828
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: Missing definition for record type author]`)
|
|
828
829
|
})
|
|
829
830
|
|
|
830
831
|
it('throws errors when loading a snapshot with a different schema', () => {
|
|
@@ -839,12 +840,12 @@ describe('snapshots', () => {
|
|
|
839
840
|
|
|
840
841
|
expect(() => {
|
|
841
842
|
store2.loadStoreSnapshot(snapshot1 as any)
|
|
842
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
843
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: Missing definition for record type author]`)
|
|
843
844
|
})
|
|
844
845
|
|
|
845
846
|
it('migrates the snapshot', () => {
|
|
846
847
|
const snapshot1 = store.getStoreSnapshot()
|
|
847
|
-
const up =
|
|
848
|
+
const up = vi.fn((s: any) => {
|
|
848
849
|
s['book:lotr'].numPages = 42
|
|
849
850
|
})
|
|
850
851
|
|
|
@@ -969,7 +970,7 @@ describe('diffs', () => {
|
|
|
969
970
|
})
|
|
970
971
|
it('produces diffs from `addHistoryInterceptor`', () => {
|
|
971
972
|
const diffs: any[] = []
|
|
972
|
-
const interceptor =
|
|
973
|
+
const interceptor = vi.fn((diff) => diffs.push(diff))
|
|
973
974
|
store.addHistoryInterceptor(interceptor)
|
|
974
975
|
|
|
975
976
|
store.put([
|
|
@@ -1095,15 +1096,15 @@ describe('callbacks', () => {
|
|
|
1095
1096
|
numPages: 1,
|
|
1096
1097
|
})
|
|
1097
1098
|
|
|
1098
|
-
let onAfterCreate:
|
|
1099
|
-
let onAfterChange:
|
|
1100
|
-
let onAfterDelete:
|
|
1099
|
+
let onAfterCreate: ReturnType<typeof vi.fn>
|
|
1100
|
+
let onAfterChange: ReturnType<typeof vi.fn>
|
|
1101
|
+
let onAfterDelete: ReturnType<typeof vi.fn>
|
|
1101
1102
|
|
|
1102
|
-
let onBeforeCreate:
|
|
1103
|
-
let onBeforeChange:
|
|
1104
|
-
let onBeforeDelete:
|
|
1103
|
+
let onBeforeCreate: ReturnType<typeof vi.fn>
|
|
1104
|
+
let onBeforeChange: ReturnType<typeof vi.fn>
|
|
1105
|
+
let onBeforeDelete: ReturnType<typeof vi.fn>
|
|
1105
1106
|
|
|
1106
|
-
let onOperationComplete:
|
|
1107
|
+
let onOperationComplete: ReturnType<typeof vi.fn>
|
|
1107
1108
|
|
|
1108
1109
|
beforeEach(() => {
|
|
1109
1110
|
store = new Store({
|
|
@@ -1113,15 +1114,15 @@ describe('callbacks', () => {
|
|
|
1113
1114
|
}),
|
|
1114
1115
|
})
|
|
1115
1116
|
|
|
1116
|
-
onAfterCreate =
|
|
1117
|
-
onAfterChange =
|
|
1118
|
-
onAfterDelete =
|
|
1117
|
+
onAfterCreate = vi.fn((record) => callbacks.push({ type: 'create', record }))
|
|
1118
|
+
onAfterChange = vi.fn((from, to) => callbacks.push({ type: 'change', from, to }))
|
|
1119
|
+
onAfterDelete = vi.fn((record) => callbacks.push({ type: 'delete', record }))
|
|
1119
1120
|
|
|
1120
|
-
onBeforeCreate =
|
|
1121
|
-
onBeforeChange =
|
|
1122
|
-
onBeforeDelete =
|
|
1121
|
+
onBeforeCreate = vi.fn((record) => record)
|
|
1122
|
+
onBeforeChange = vi.fn((_from, to) => to)
|
|
1123
|
+
onBeforeDelete = vi.fn((_record) => {})
|
|
1123
1124
|
|
|
1124
|
-
onOperationComplete =
|
|
1125
|
+
onOperationComplete = vi.fn(() => callbacks.push({ type: 'complete' }))
|
|
1125
1126
|
callbacks = []
|
|
1126
1127
|
|
|
1127
1128
|
store.sideEffects.registerAfterCreateHandler('book', onAfterCreate)
|
|
@@ -1161,12 +1162,12 @@ describe('callbacks', () => {
|
|
|
1161
1162
|
|
|
1162
1163
|
it('bails out if too many callbacks are fired', () => {
|
|
1163
1164
|
let limit = 10
|
|
1164
|
-
onAfterCreate.mockImplementation((record) => {
|
|
1165
|
+
onAfterCreate.mockImplementation((record: any) => {
|
|
1165
1166
|
if (record.numPages < limit) {
|
|
1166
1167
|
store.put([{ ...record, numPages: record.numPages + 1 }])
|
|
1167
1168
|
}
|
|
1168
1169
|
})
|
|
1169
|
-
onAfterChange.mockImplementation((from, to) => {
|
|
1170
|
+
onAfterChange.mockImplementation((from: any, to: any) => {
|
|
1170
1171
|
if (to.numPages < limit) {
|
|
1171
1172
|
store.put([{ ...to, numPages: to.numPages + 1 }])
|
|
1172
1173
|
}
|
|
@@ -1181,7 +1182,9 @@ describe('callbacks', () => {
|
|
|
1181
1182
|
store.clear()
|
|
1182
1183
|
expect(() => {
|
|
1183
1184
|
store.put([book2])
|
|
1184
|
-
}).toThrowErrorMatchingInlineSnapshot(
|
|
1185
|
+
}).toThrowErrorMatchingInlineSnapshot(
|
|
1186
|
+
`[Error: Maximum store update depth exceeded, bailing out]`
|
|
1187
|
+
)
|
|
1185
1188
|
})
|
|
1186
1189
|
|
|
1187
1190
|
it('keeps firing operation complete callbacks until all are cleared', () => {
|
|
@@ -1197,7 +1200,7 @@ describe('callbacks', () => {
|
|
|
1197
1200
|
|
|
1198
1201
|
store.put([book1])
|
|
1199
1202
|
|
|
1200
|
-
onAfterChange.mockImplementation((prev, next) => {
|
|
1203
|
+
onAfterChange.mockImplementation((prev: any, next: any) => {
|
|
1201
1204
|
if ([0, 1, 2, 5, 6].includes(step)) {
|
|
1202
1205
|
step++
|
|
1203
1206
|
store.put([{ ...next, numPages: next.numPages + 1 }])
|
|
@@ -34,18 +34,18 @@ describe(sortMigrations, () => {
|
|
|
34
34
|
it('should fail if a cycle is created', () => {
|
|
35
35
|
expect(() => {
|
|
36
36
|
sort([m('foo/1', { dependsOn: ['foo/1'] })])
|
|
37
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
37
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: Circular dependency in migrations: foo/1]`)
|
|
38
38
|
|
|
39
39
|
expect(() => {
|
|
40
40
|
sort([m('foo/1', { dependsOn: ['foo/2'] }), m('foo/2')])
|
|
41
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
41
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: Circular dependency in migrations: foo/1]`)
|
|
42
42
|
|
|
43
43
|
expect(() => {
|
|
44
44
|
sort([m('foo/1', { dependsOn: ['bar/1'] }), m('bar/1', { dependsOn: ['foo/1'] })])
|
|
45
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
45
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: Circular dependency in migrations: foo/1]`)
|
|
46
46
|
|
|
47
47
|
expect(() => {
|
|
48
48
|
sort([m('bar/1', { dependsOn: ['foo/1'] }), m('foo/1', { dependsOn: ['bar/1'] })])
|
|
49
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
49
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: Circular dependency in migrations: bar/1]`)
|
|
50
50
|
})
|
|
51
51
|
})
|
|
@@ -18,7 +18,7 @@ describe(validateMigrations, () => {
|
|
|
18
18
|
sequenceId: 'foo',
|
|
19
19
|
})
|
|
20
20
|
).toThrowErrorMatchingInlineSnapshot(
|
|
21
|
-
`
|
|
21
|
+
`[Error: Every migration in sequence 'foo' must have an id starting with 'foo/'. Got invalid id: 'foo.1']`
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
expect(() =>
|
|
@@ -36,7 +36,7 @@ describe(validateMigrations, () => {
|
|
|
36
36
|
|
|
37
37
|
sequenceId: 'foo',
|
|
38
38
|
})
|
|
39
|
-
).toThrowErrorMatchingInlineSnapshot(`
|
|
39
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: Invalid migration id: 'foo/one']`)
|
|
40
40
|
|
|
41
41
|
expect(() =>
|
|
42
42
|
validateMigrations({
|
|
@@ -61,7 +61,7 @@ describe(validateMigrations, () => {
|
|
|
61
61
|
sequenceId: 'foo',
|
|
62
62
|
})
|
|
63
63
|
).toThrowErrorMatchingInlineSnapshot(
|
|
64
|
-
`
|
|
64
|
+
`[Error: Every migration in sequence 'foo' must have an id starting with 'foo/'. Got invalid id: 'foo.2']`
|
|
65
65
|
)
|
|
66
66
|
|
|
67
67
|
expect(() =>
|
|
@@ -86,7 +86,7 @@ describe(validateMigrations, () => {
|
|
|
86
86
|
|
|
87
87
|
sequenceId: 'foo',
|
|
88
88
|
})
|
|
89
|
-
).toThrowErrorMatchingInlineSnapshot(`
|
|
89
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: Invalid migration id: 'foo/two']`)
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
it('should throw if the sequenceId is invalid', () => {
|
|
@@ -96,7 +96,7 @@ describe(validateMigrations, () => {
|
|
|
96
96
|
sequence: [],
|
|
97
97
|
sequenceId: 'foo/bar',
|
|
98
98
|
})
|
|
99
|
-
).toThrowErrorMatchingInlineSnapshot(`
|
|
99
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: sequenceId cannot contain a '/', got foo/bar]`)
|
|
100
100
|
|
|
101
101
|
expect(() =>
|
|
102
102
|
validateMigrations({
|
|
@@ -104,7 +104,7 @@ describe(validateMigrations, () => {
|
|
|
104
104
|
sequence: [],
|
|
105
105
|
sequenceId: '',
|
|
106
106
|
})
|
|
107
|
-
).toThrowErrorMatchingInlineSnapshot(`
|
|
107
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: sequenceId must be a non-empty string]`)
|
|
108
108
|
})
|
|
109
109
|
|
|
110
110
|
it('should throw if the version numbers do not start at 1', () => {
|
|
@@ -124,7 +124,7 @@ describe(validateMigrations, () => {
|
|
|
124
124
|
sequenceId: 'foo',
|
|
125
125
|
})
|
|
126
126
|
).toThrowErrorMatchingInlineSnapshot(
|
|
127
|
-
`
|
|
127
|
+
`[Error: Expected the first migrationId to be 'foo/1' but got 'foo/2']`
|
|
128
128
|
)
|
|
129
129
|
})
|
|
130
130
|
|
|
@@ -159,7 +159,7 @@ describe(validateMigrations, () => {
|
|
|
159
159
|
sequenceId: 'foo',
|
|
160
160
|
})
|
|
161
161
|
).toThrowErrorMatchingInlineSnapshot(
|
|
162
|
-
`
|
|
162
|
+
`[Error: Migration id numbers must increase in increments of 1, expected foo/3 but got 'foo/4']`
|
|
163
163
|
)
|
|
164
164
|
})
|
|
165
165
|
})
|