@tldraw/store 3.16.0-next.15f085081fd5 → 3.16.0-next.2f9d39693e4c

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,232 +0,0 @@
1
- import { defineMigrations } from '../migrate'
2
-
3
- const Versions = {
4
- Initial: 0,
5
- January: 1,
6
- February: 2,
7
- March: 3,
8
- } as const
9
-
10
- describe('define migrations tests', () => {
11
- it('defines migrations', () => {
12
- expect(() => {
13
- // no versions
14
- // eslint-disable-next-line @typescript-eslint/no-deprecated
15
- defineMigrations({
16
- firstVersion: Versions.Initial,
17
- })
18
- }).not.toThrow()
19
-
20
- expect(() => {
21
- // no versions
22
- // eslint-disable-next-line @typescript-eslint/no-deprecated
23
- defineMigrations({
24
- firstVersion: Versions.February,
25
- })
26
- }).not.toThrow()
27
-
28
- expect(() => {
29
- // empty migrators
30
- // eslint-disable-next-line @typescript-eslint/no-deprecated
31
- defineMigrations({
32
- migrators: {},
33
- })
34
- }).not.toThrow()
35
-
36
- expect(() => {
37
- // no versions!
38
- // eslint-disable-next-line @typescript-eslint/no-deprecated
39
- defineMigrations({
40
- migrators: {
41
- [Versions.February]: {
42
- up: (rec: any) => rec,
43
- down: (rec: any) => rec,
44
- },
45
- },
46
- })
47
- }).not.toThrow()
48
-
49
- expect(() => {
50
- // wrong current version!
51
- // eslint-disable-next-line @typescript-eslint/no-deprecated
52
- defineMigrations({
53
- currentVersion: Versions.January,
54
- migrators: {
55
- [Versions.February]: {
56
- up: (rec: any) => rec,
57
- down: (rec: any) => rec,
58
- },
59
- },
60
- })
61
- }).not.toThrow()
62
-
63
- expect(() => {
64
- // eslint-disable-next-line @typescript-eslint/no-deprecated
65
- defineMigrations({
66
- currentVersion: Versions.February,
67
- migrators: {
68
- // has a default zero version
69
- [Versions.January]: {
70
- up: (rec: any) => rec,
71
- down: (rec: any) => rec,
72
- },
73
- // has a current version
74
- [Versions.February]: {
75
- up: (rec: any) => rec,
76
- down: (rec: any) => rec,
77
- },
78
- },
79
- })
80
- }).not.toThrow()
81
-
82
- expect(() => {
83
- // can't provide only first version
84
- // eslint-disable-next-line @typescript-eslint/no-deprecated
85
- defineMigrations({
86
- firstVersion: Versions.January,
87
- migrators: {},
88
- })
89
- }).not.toThrow()
90
-
91
- expect(() => {
92
- // same version
93
- // eslint-disable-next-line @typescript-eslint/no-deprecated
94
- defineMigrations({
95
- firstVersion: Versions.Initial,
96
- currentVersion: Versions.Initial,
97
- migrators: {},
98
- })
99
- }).toThrow()
100
-
101
- expect(() => {
102
- // only first version
103
- // eslint-disable-next-line @typescript-eslint/no-deprecated
104
- defineMigrations({
105
- firstVersion: Versions.January,
106
- migrators: {},
107
- })
108
- }).not.toThrow()
109
-
110
- expect(() => {
111
- // missing only version
112
- // eslint-disable-next-line @typescript-eslint/no-deprecated
113
- defineMigrations({
114
- firstVersion: Versions.January,
115
- currentVersion: Versions.January,
116
- migrators: {},
117
- })
118
- }).toThrow()
119
-
120
- expect(() => {
121
- // only version, explicit start and current
122
- // eslint-disable-next-line @typescript-eslint/no-deprecated
123
- defineMigrations({
124
- firstVersion: Versions.January,
125
- currentVersion: Versions.January,
126
- migrators: {
127
- [Versions.January]: {
128
- up: (rec: any) => rec,
129
- down: (rec: any) => rec,
130
- },
131
- },
132
- })
133
- }).toThrow()
134
-
135
- expect(() => {
136
- // missing later versions
137
- // eslint-disable-next-line @typescript-eslint/no-deprecated
138
- defineMigrations({
139
- firstVersion: Versions.January,
140
- currentVersion: Versions.February,
141
- migrators: {},
142
- })
143
- }).not.toThrow()
144
-
145
- expect(() => {
146
- // missing later versions
147
- // eslint-disable-next-line @typescript-eslint/no-deprecated
148
- defineMigrations({
149
- firstVersion: Versions.Initial,
150
- currentVersion: Versions.February,
151
- migrators: {
152
- [Versions.January]: {
153
- up: (rec: any) => rec,
154
- down: (rec: any) => rec,
155
- },
156
- },
157
- })
158
- }).not.toThrow()
159
-
160
- expect(() => {
161
- // missing earlier versions
162
- // eslint-disable-next-line @typescript-eslint/no-deprecated
163
- defineMigrations({
164
- firstVersion: Versions.Initial,
165
- currentVersion: Versions.February,
166
- migrators: {
167
- [Versions.February]: {
168
- up: (rec: any) => rec,
169
- down: (rec: any) => rec,
170
- },
171
- },
172
- })
173
- }).not.toThrow()
174
-
175
- expect(() => {
176
- // got em all
177
- // eslint-disable-next-line @typescript-eslint/no-deprecated
178
- defineMigrations({
179
- firstVersion: Versions.Initial,
180
- currentVersion: Versions.February,
181
- migrators: {
182
- [Versions.January]: {
183
- up: (rec: any) => rec,
184
- down: (rec: any) => rec,
185
- },
186
- [Versions.February]: {
187
- up: (rec: any) => rec,
188
- down: (rec: any) => rec,
189
- },
190
- },
191
- })
192
- }).not.toThrow()
193
-
194
- expect(() => {
195
- // got em all starting later
196
- // eslint-disable-next-line @typescript-eslint/no-deprecated
197
- defineMigrations({
198
- firstVersion: Versions.January,
199
- currentVersion: Versions.March,
200
- migrators: {
201
- [Versions.February]: {
202
- up: (rec: any) => rec,
203
- down: (rec: any) => rec,
204
- },
205
- [Versions.March]: {
206
- up: (rec: any) => rec,
207
- down: (rec: any) => rec,
208
- },
209
- },
210
- })
211
- }).not.toThrow()
212
-
213
- expect(() => {
214
- // first migration should be first version + 1
215
- // eslint-disable-next-line @typescript-eslint/no-deprecated
216
- defineMigrations({
217
- firstVersion: Versions.February,
218
- currentVersion: Versions.March,
219
- migrators: {
220
- [Versions.February]: {
221
- up: (rec: any) => rec,
222
- down: (rec: any) => rec,
223
- },
224
- [Versions.March]: {
225
- up: (rec: any) => rec,
226
- down: (rec: any) => rec,
227
- },
228
- },
229
- })
230
- }).not.toThrow()
231
- })
232
- })