@casual-simulation/aux-common 3.0.9 → 3.0.11

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.
Files changed (49) hide show
  1. package/aux-format-2/AuxCausalTree2.js +40 -5
  2. package/aux-format-2/AuxCausalTree2.js.map +1 -1
  3. package/bots/Bot.d.ts +8 -0
  4. package/bots/Bot.js +10 -0
  5. package/bots/Bot.js.map +1 -1
  6. package/bots/BotCalculations.d.ts +46 -6
  7. package/bots/BotCalculations.js +171 -14
  8. package/bots/BotCalculations.js.map +1 -1
  9. package/bots/BotEvents.d.ts +108 -22
  10. package/bots/BotEvents.js +56 -25
  11. package/bots/BotEvents.js.map +1 -1
  12. package/bots/test/BotCalculationContextTests.js +58 -6
  13. package/bots/test/BotCalculationContextTests.js.map +1 -1
  14. package/bots/test/BotTestHelpers.d.ts +4 -0
  15. package/bots/test/BotTestHelpers.js +67 -0
  16. package/bots/test/BotTestHelpers.js.map +1 -1
  17. package/math/Quaternion.d.ts +94 -0
  18. package/math/Quaternion.js +128 -0
  19. package/math/Quaternion.js.map +1 -0
  20. package/math/Rotation.d.ts +274 -0
  21. package/math/Rotation.js +378 -0
  22. package/math/Rotation.js.map +1 -0
  23. package/math/Vector2.d.ts +251 -0
  24. package/math/Vector2.js +287 -0
  25. package/math/Vector2.js.map +1 -0
  26. package/math/Vector3.d.ts +318 -0
  27. package/math/Vector3.js +370 -0
  28. package/math/Vector3.js.map +1 -0
  29. package/math/index.d.ts +5 -0
  30. package/math/index.js +5 -0
  31. package/math/index.js.map +1 -0
  32. package/package.json +4 -4
  33. package/partitions/MemoryPartition.js +23 -4
  34. package/partitions/MemoryPartition.js.map +1 -1
  35. package/partitions/RemoteYjsPartition.js +8 -4
  36. package/partitions/RemoteYjsPartition.js.map +1 -1
  37. package/partitions/YjsPartition.js +8 -0
  38. package/partitions/YjsPartition.js.map +1 -1
  39. package/runtime/AuxLibrary.d.ts +21 -44
  40. package/runtime/AuxLibrary.js +278 -95
  41. package/runtime/AuxLibrary.js.map +1 -1
  42. package/runtime/AuxLibraryDefinitions.def +642 -20
  43. package/runtime/AuxRuntime.js +26 -1
  44. package/runtime/AuxRuntime.js.map +1 -1
  45. package/runtime/Utils.js +12 -4
  46. package/runtime/Utils.js.map +1 -1
  47. package/partitions/test/PartitionTests.d.ts +0 -8
  48. package/partitions/test/PartitionTests.js +0 -1548
  49. package/partitions/test/PartitionTests.js.map +0 -1
@@ -1,1548 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { getPartitionState } from '../AuxPartition';
11
- import { botAdded, createBot, botRemoved, botUpdated, stateUpdatedEvent, hasValue, } from '../../bots';
12
- import { Subscription } from 'rxjs';
13
- import { waitAsync } from '../../test/TestHelpers';
14
- import { takeWhile, bufferCount, skip, } from 'rxjs/operators';
15
- import { del, edit, edits, insert, preserve, } from '../../aux-format-2';
16
- import faker from 'faker';
17
- import { generateRandomEditCases, generateRandomEditParagraphCases, } from '../../test/FuzzingHelpers';
18
- /**
19
- * Tests the given partition implementation for various features.
20
- * @param createPartition A function that creates a new instance of the partition that should be tested.
21
- * @param testForMergedEdits Whether to test that multiple edit sequences are merged instead of preserved as separate sequences.
22
- */
23
- export function testPartitionImplementation(createPartition, testForMergedEdits = false, testConcurrentEdits = false) {
24
- let partition;
25
- let added;
26
- let removed;
27
- let updated;
28
- let statuses;
29
- let updates;
30
- let version;
31
- let sub;
32
- beforeEach(() => __awaiter(this, void 0, void 0, function* () {
33
- sub = new Subscription();
34
- partition = yield createPartition();
35
- added = [];
36
- removed = [];
37
- updated = [];
38
- statuses = [];
39
- updates = [];
40
- sub.add(partition.onBotsAdded.subscribe((bots) => added.push(...bots)));
41
- sub.add(partition.onBotsRemoved.subscribe((ids) => removed.push(...ids)));
42
- sub.add(partition.onBotsUpdated.subscribe((updates) => updated.push(...updates)));
43
- sub.add(partition.onStateUpdated
44
- .pipe(skip(1))
45
- .subscribe((u) => updates.push(u)));
46
- sub.add(partition.onVersionUpdated.subscribe((v) => (version = v)));
47
- sub.add(partition.onStatusUpdated.subscribe((update) => statuses.push(update)));
48
- }));
49
- afterEach(() => {
50
- sub.unsubscribe();
51
- });
52
- describe('add_bot', () => {
53
- it('should be able to add a bot to the partition', () => __awaiter(this, void 0, void 0, function* () {
54
- const bot = createBot('test', {
55
- abc: 'def',
56
- });
57
- yield partition.applyEvents([botAdded(bot)]);
58
- yield waitAsync();
59
- expect(added).toEqual([bot]);
60
- expect(updates).toEqual([
61
- {
62
- state: {
63
- test: bot,
64
- },
65
- addedBots: ['test'],
66
- removedBots: [],
67
- updatedBots: [],
68
- },
69
- ]);
70
- expect(partition.state).toEqual({
71
- test: bot,
72
- });
73
- }));
74
- it('should be able to add multiple bots to the partition at a time', () => __awaiter(this, void 0, void 0, function* () {
75
- const bot1 = createBot('test', {
76
- abc: 'def',
77
- });
78
- const bot2 = createBot('test2', {
79
- abc: 'xyz',
80
- });
81
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
82
- yield waitAsync();
83
- expect(added).toEqual([bot1, bot2]);
84
- expect(partition.state).toEqual({
85
- test: bot1,
86
- test2: bot2,
87
- });
88
- }));
89
- it('should issue an event for all the existing bots upon subscription', () => __awaiter(this, void 0, void 0, function* () {
90
- const bot1 = createBot('test', {
91
- abc: 'def',
92
- });
93
- const bot2 = createBot('test2', {
94
- abc: 'xyz',
95
- });
96
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
97
- let added = [];
98
- partition.onBotsAdded.subscribe((a) => added.push(...a));
99
- expect(added).toEqual([bot1, bot2]);
100
- expect(partition.state).toEqual({
101
- [bot1.id]: bot1,
102
- [bot2.id]: bot2,
103
- });
104
- }));
105
- it('should issue an state updated event for the existing state upon subscription', () => __awaiter(this, void 0, void 0, function* () {
106
- const bot1 = createBot('test', {
107
- abc: 'def',
108
- });
109
- const bot2 = createBot('test2', {
110
- abc: 'xyz',
111
- });
112
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
113
- let updates = [];
114
- partition.onStateUpdated.subscribe((e) => updates.push(e));
115
- expect(updates).toEqual([
116
- {
117
- state: {
118
- test: createBot('test', {
119
- abc: 'def',
120
- }),
121
- test2: createBot('test2', {
122
- abc: 'xyz',
123
- }),
124
- },
125
- addedBots: ['test', 'test2'],
126
- removedBots: [],
127
- updatedBots: [],
128
- },
129
- ]);
130
- expect(partition.state).toEqual({
131
- test: bot1,
132
- test2: bot2,
133
- });
134
- }));
135
- it('should add bots to the configured space.', () => __awaiter(this, void 0, void 0, function* () {
136
- const bot1 = createBot('test', {
137
- abc: 'def',
138
- });
139
- const bot2 = createBot('test2', {
140
- abc: 'xyz',
141
- });
142
- let added = [];
143
- partition.onBotsAdded.subscribe((a) => added.push(...a));
144
- partition.space = 'test';
145
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
146
- expect(added).toEqual([
147
- createBot('test', {
148
- abc: 'def',
149
- }, 'test'),
150
- createBot('test2', {
151
- abc: 'xyz',
152
- }, 'test'),
153
- ]);
154
- expect(partition.state).toEqual({
155
- test: createBot('test', {
156
- abc: 'def',
157
- }, 'test'),
158
- test2: createBot('test2', {
159
- abc: 'xyz',
160
- }, 'test'),
161
- });
162
- }));
163
- });
164
- describe('remove_bot', () => {
165
- it('should be able to remove a bot from the partition', () => __awaiter(this, void 0, void 0, function* () {
166
- const bot = createBot('test', {
167
- abc: 'def',
168
- });
169
- // Run the bot added and updated
170
- // events in separate batches
171
- // because partitions may combine the events
172
- yield partition.applyEvents([botAdded(bot)]);
173
- yield partition.applyEvents([botRemoved('test')]);
174
- yield waitAsync();
175
- expect(removed).toEqual(['test']);
176
- expect(updates.slice(1)).toEqual([
177
- {
178
- state: {
179
- test: null,
180
- },
181
- addedBots: [],
182
- removedBots: ['test'],
183
- updatedBots: [],
184
- },
185
- ]);
186
- expect(partition.state).toEqual({});
187
- }));
188
- it('should be able to remove multiple bots from the partition', () => __awaiter(this, void 0, void 0, function* () {
189
- const bot1 = createBot('test', {
190
- abc: 'def',
191
- });
192
- const bot2 = createBot('test2', {
193
- abc: 'xyz',
194
- });
195
- // Run the bot added and updated
196
- // events in separate batches
197
- // because partitions may combine the events
198
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
199
- yield partition.applyEvents([
200
- botRemoved('test2'),
201
- botRemoved('test'),
202
- ]);
203
- yield waitAsync();
204
- expect(removed).toEqual(['test2', 'test']);
205
- expect(updates.slice(1)).toEqual([
206
- {
207
- state: {
208
- test: null,
209
- test2: null,
210
- },
211
- addedBots: [],
212
- removedBots: ['test2', 'test'],
213
- updatedBots: [],
214
- },
215
- ]);
216
- expect(partition.state).toEqual({});
217
- }));
218
- it('should be able to remove a bot that was just added to the partition', () => __awaiter(this, void 0, void 0, function* () {
219
- const bot1 = createBot('test', {
220
- abc: 'def',
221
- });
222
- // Run the bot added and updated
223
- // events in separate batches
224
- // because partitions may combine the events
225
- yield partition.applyEvents([botAdded(bot1), botRemoved('test')]);
226
- yield waitAsync();
227
- expect(added).toEqual([]);
228
- expect(updated).toEqual([]);
229
- expect(removed).toEqual([]);
230
- expect(partition.state).toEqual({});
231
- }));
232
- });
233
- describe('update_bot', () => {
234
- it('should be able to update a bot in the partition', () => __awaiter(this, void 0, void 0, function* () {
235
- const bot = createBot('test', {
236
- abc: 'def',
237
- });
238
- // Run the bot added and updated
239
- // events in separate batches
240
- // because partitions may combine the events
241
- yield partition.applyEvents([botAdded(bot)]);
242
- yield partition.applyEvents([
243
- botUpdated('test', {
244
- tags: {
245
- abc: 'ghi',
246
- },
247
- }),
248
- ]);
249
- yield waitAsync();
250
- expect(updated).toEqual([
251
- {
252
- bot: createBot('test', {
253
- abc: 'ghi',
254
- }),
255
- tags: ['abc'],
256
- },
257
- ]);
258
- expect(updates.slice(1)).toEqual([
259
- {
260
- state: {
261
- test: {
262
- tags: {
263
- abc: 'ghi',
264
- },
265
- },
266
- },
267
- addedBots: [],
268
- removedBots: [],
269
- updatedBots: ['test'],
270
- },
271
- ]);
272
- }));
273
- it('should be able to update multiple bots at the same time', () => __awaiter(this, void 0, void 0, function* () {
274
- const bot1 = createBot('test1', {
275
- abc: 'def',
276
- });
277
- const bot2 = createBot('test2', {
278
- number: 123,
279
- });
280
- // Run the bot added and updated
281
- // events in separate batches
282
- // because partitions may combine the events
283
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
284
- yield partition.applyEvents([
285
- botUpdated('test1', {
286
- tags: {
287
- abc: 'ghi',
288
- },
289
- }),
290
- botUpdated('test2', {
291
- tags: {
292
- number: 456,
293
- },
294
- }),
295
- ]);
296
- yield waitAsync();
297
- expect(updated).toEqual([
298
- {
299
- bot: createBot('test1', {
300
- abc: 'ghi',
301
- }),
302
- tags: ['abc'],
303
- },
304
- {
305
- bot: createBot('test2', {
306
- number: 456,
307
- }),
308
- tags: ['number'],
309
- },
310
- ]);
311
- expect(updates.slice(1)).toEqual([
312
- {
313
- state: {
314
- test1: {
315
- tags: {
316
- abc: 'ghi',
317
- },
318
- },
319
- test2: {
320
- tags: {
321
- number: 456,
322
- },
323
- },
324
- },
325
- addedBots: [],
326
- removedBots: [],
327
- updatedBots: ['test1', 'test2'],
328
- },
329
- ]);
330
- }));
331
- it('should report tags that were added to the bot', () => __awaiter(this, void 0, void 0, function* () {
332
- const bot = createBot('test', {
333
- abc: 'def',
334
- });
335
- // Run the bot added and updated
336
- // events in separate batches
337
- // because partitions may combine the events
338
- yield partition.applyEvents([botAdded(bot)]);
339
- yield partition.applyEvents([
340
- botUpdated('test', {
341
- tags: {
342
- hahaha: true,
343
- },
344
- }),
345
- ]);
346
- yield waitAsync();
347
- expect(updated).toEqual([
348
- {
349
- bot: createBot('test', {
350
- abc: 'def',
351
- hahaha: true,
352
- }),
353
- tags: ['hahaha'],
354
- },
355
- ]);
356
- }));
357
- it('should report tags that were removed from the bot', () => __awaiter(this, void 0, void 0, function* () {
358
- const bot = createBot('test', {
359
- abc: 'def',
360
- example: 123,
361
- });
362
- // Run the bot added and updated
363
- // events in separate batches
364
- // because partitions may combine the events
365
- yield partition.applyEvents([botAdded(bot)]);
366
- yield partition.applyEvents([
367
- botUpdated('test', {
368
- tags: {
369
- example: null,
370
- },
371
- }),
372
- ]);
373
- yield waitAsync();
374
- expect(updated).toEqual([
375
- {
376
- bot: createBot('test', {
377
- abc: 'def',
378
- }),
379
- tags: ['example'],
380
- },
381
- ]);
382
- }));
383
- it('should ignore updates that dont change any tags', () => __awaiter(this, void 0, void 0, function* () {
384
- const bot = createBot('test', {
385
- abc: 'def',
386
- example: 123,
387
- });
388
- // Run the bot added and updated
389
- // events in separate batches
390
- // because partitions may combine the events
391
- yield partition.applyEvents([botAdded(bot)]);
392
- yield partition.applyEvents([botUpdated('test', {})]);
393
- yield waitAsync();
394
- expect(updated).toEqual([]);
395
- }));
396
- it('should ignore updates that set tag values to the same value that it is currently at', () => __awaiter(this, void 0, void 0, function* () {
397
- const bot = createBot('test', {
398
- abc: 'def',
399
- example: 123,
400
- });
401
- // Run the bot added and updated
402
- // events in separate batches
403
- // because partitions may combine the events
404
- yield partition.applyEvents([botAdded(bot)]);
405
- yield partition.applyEvents([
406
- botUpdated('test', {
407
- tags: {
408
- abc: 'def',
409
- },
410
- }),
411
- ]);
412
- yield waitAsync();
413
- expect(updated).toEqual([]);
414
- }));
415
- it('should support updates to arrays that keep the same array instance', () => __awaiter(this, void 0, void 0, function* () {
416
- let arr = [];
417
- const bot = createBot('test', {
418
- array: arr,
419
- });
420
- // Run the bot added and updated
421
- // events in separate batches
422
- // because partitions may combine the events
423
- yield partition.applyEvents([botAdded(bot)]);
424
- yield partition.applyEvents([
425
- botUpdated('test', {
426
- tags: {
427
- array: arr,
428
- },
429
- }),
430
- ]);
431
- yield waitAsync();
432
- expect(updates.slice(1)).toEqual([
433
- stateUpdatedEvent({
434
- test: {
435
- tags: {
436
- array: arr,
437
- },
438
- },
439
- }),
440
- ]);
441
- expect(updated).toEqual([
442
- {
443
- bot: createBot('test', {
444
- array: arr,
445
- }),
446
- tags: ['array'],
447
- },
448
- ]);
449
- }));
450
- it('should only report tags that changed', () => __awaiter(this, void 0, void 0, function* () {
451
- const bot = createBot('test', {
452
- abc: 'def',
453
- example: 123,
454
- });
455
- // Run the bot added and updated
456
- // events in separate batches
457
- // because partitions may combine the events
458
- yield partition.applyEvents([botAdded(bot)]);
459
- yield partition.applyEvents([
460
- botUpdated('test', {
461
- tags: {
462
- abc: 'def',
463
- example: 456,
464
- },
465
- }),
466
- ]);
467
- yield waitAsync();
468
- expect(updated).toEqual([
469
- {
470
- bot: createBot('test', {
471
- abc: 'def',
472
- example: 456,
473
- }),
474
- tags: ['example'],
475
- },
476
- ]);
477
- }));
478
- it('should merge multiple updates to the same bot', () => __awaiter(this, void 0, void 0, function* () {
479
- const bot = createBot('test', {
480
- abc: 'def',
481
- example: 123,
482
- });
483
- // Run the bot added and updated
484
- // events in separate batches
485
- // because partitions may combine the events
486
- yield partition.applyEvents([botAdded(bot)]);
487
- yield partition.applyEvents([
488
- botUpdated('test', {
489
- tags: {
490
- abc: 'rgb',
491
- },
492
- }),
493
- botUpdated('test', {
494
- tags: {
495
- example: 456,
496
- },
497
- }),
498
- ]);
499
- yield waitAsync();
500
- expect(updated).toEqual([
501
- {
502
- bot: createBot('test', {
503
- abc: 'rgb',
504
- example: 456,
505
- }),
506
- tags: ['abc', 'example'],
507
- },
508
- ]);
509
- expect(updates.slice(1)).toEqual([
510
- {
511
- state: {
512
- test: {
513
- tags: {
514
- abc: 'rgb',
515
- example: 456,
516
- },
517
- },
518
- },
519
- addedBots: [],
520
- removedBots: [],
521
- updatedBots: ['test'],
522
- },
523
- ]);
524
- }));
525
- it('should ignore updates to bots that dont exist', () => __awaiter(this, void 0, void 0, function* () {
526
- yield partition.applyEvents([
527
- botUpdated('test', {
528
- tags: {
529
- abc: 'def',
530
- },
531
- }),
532
- ]);
533
- yield waitAsync();
534
- expect(updated).toEqual([]);
535
- }));
536
- let deleteValueCases = [
537
- ['null', null],
538
- ['undefined', undefined],
539
- ['empty string', ''],
540
- ];
541
- let preserveValueCases = [
542
- ['0', 0],
543
- ['false', false],
544
- ['whitespace', ' '],
545
- ];
546
- it.each(deleteValueCases)('should delete tags with %s values', (desc, val) => __awaiter(this, void 0, void 0, function* () {
547
- const bot = createBot('test', {
548
- abc: 'def',
549
- example: 123,
550
- });
551
- // Run the bot added and updated
552
- // events in separate batches
553
- // because partitions may combine the events
554
- yield partition.applyEvents([botAdded(bot)]);
555
- yield partition.applyEvents([
556
- botUpdated('test', {
557
- tags: {
558
- example: val,
559
- },
560
- }),
561
- ]);
562
- yield waitAsync();
563
- expect(updated).toEqual([
564
- {
565
- bot: createBot('test', {
566
- abc: 'def',
567
- }),
568
- tags: ['example'],
569
- },
570
- ]);
571
- expect(updates.slice(1)).toEqual([
572
- {
573
- state: {
574
- test: {
575
- tags: {
576
- example: null,
577
- },
578
- },
579
- },
580
- addedBots: [],
581
- removedBots: [],
582
- updatedBots: ['test'],
583
- },
584
- ]);
585
- }));
586
- it.each(preserveValueCases)('should preserve tags with %s values', (desc, val) => __awaiter(this, void 0, void 0, function* () {
587
- const bot = createBot('test', {
588
- abc: 'def',
589
- example: 123,
590
- });
591
- // Run the bot added and updated
592
- // events in separate batches
593
- // because partitions may combine the events
594
- yield partition.applyEvents([botAdded(bot)]);
595
- yield partition.applyEvents([
596
- botUpdated('test', {
597
- tags: {
598
- example: val,
599
- },
600
- }),
601
- ]);
602
- yield waitAsync();
603
- expect(updated).toEqual([
604
- {
605
- bot: createBot('test', {
606
- abc: 'def',
607
- example: val,
608
- }),
609
- tags: ['example'],
610
- },
611
- ]);
612
- expect(updates.slice(1)).toEqual([
613
- {
614
- state: {
615
- test: {
616
- tags: {
617
- example: val,
618
- },
619
- },
620
- },
621
- addedBots: [],
622
- removedBots: [],
623
- updatedBots: ['test'],
624
- },
625
- ]);
626
- }));
627
- describe('edits', () => {
628
- it('should support inserting text into a tag value', () => __awaiter(this, void 0, void 0, function* () {
629
- yield partition.applyEvents([
630
- botAdded(createBot('test', {
631
- abc: 'def',
632
- })),
633
- ]);
634
- yield waitAsync();
635
- const editVersion = Object.assign({}, version.vector);
636
- yield partition.applyEvents([
637
- botUpdated('test', {
638
- tags: {
639
- abc: edit(editVersion, insert('ghi')),
640
- },
641
- }),
642
- ]);
643
- expect(partition.state).toEqual({
644
- test: createBot('test', {
645
- abc: 'ghidef',
646
- }),
647
- });
648
- expect(updates.slice(1)).toEqual([
649
- stateUpdatedEvent({
650
- test: {
651
- tags: {
652
- abc: edit(version.vector, insert('ghi')),
653
- },
654
- },
655
- }),
656
- ]);
657
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
658
- }));
659
- it('should support deleting text from a tag value', () => __awaiter(this, void 0, void 0, function* () {
660
- yield partition.applyEvents([
661
- botAdded(createBot('test', {
662
- abc: 'def',
663
- })),
664
- ]);
665
- yield waitAsync();
666
- const editVersion = Object.assign({}, version.vector);
667
- yield partition.applyEvents([
668
- botUpdated('test', {
669
- tags: {
670
- abc: edit(editVersion, del(2)),
671
- },
672
- }),
673
- ]);
674
- expect(partition.state).toEqual({
675
- test: createBot('test', {
676
- abc: 'f',
677
- }),
678
- });
679
- expect(updates.slice(1)).toEqual([
680
- stateUpdatedEvent({
681
- test: {
682
- tags: {
683
- abc: edit(version.vector, del(2)),
684
- },
685
- },
686
- }),
687
- ]);
688
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
689
- }));
690
- it('should support deletes in multiple edit sequences', () => __awaiter(this, void 0, void 0, function* () {
691
- yield partition.applyEvents([
692
- botAdded(createBot('test', {
693
- abc: 'abcdefghijklmnop',
694
- })),
695
- ]);
696
- yield waitAsync();
697
- const editVersion = Object.assign({}, version.vector);
698
- yield partition.applyEvents([
699
- botUpdated('test', {
700
- tags: {
701
- abc: edits(editVersion, [preserve(3), del(3)], [preserve(6), del(3)]),
702
- },
703
- }),
704
- ]);
705
- expect(partition.state).toEqual({
706
- test: createBot('test', {
707
- abc: 'abcghimnop',
708
- }),
709
- });
710
- expect(updates.slice(1)).toEqual([
711
- stateUpdatedEvent({
712
- test: {
713
- tags: {
714
- abc: testForMergedEdits
715
- ? edits(version.vector, [
716
- preserve(3),
717
- del(3),
718
- preserve(3),
719
- del(3),
720
- ])
721
- : edits(version.vector, [preserve(3), del(3)], [preserve(6), del(3)]),
722
- },
723
- },
724
- }),
725
- ]);
726
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
727
- }));
728
- it('should support inserts in multiple edit sequences', () => __awaiter(this, void 0, void 0, function* () {
729
- yield partition.applyEvents([
730
- botAdded(createBot('test', {
731
- abc: 'abcdef',
732
- })),
733
- ]);
734
- yield waitAsync();
735
- const editVersion = Object.assign({}, version.vector);
736
- yield partition.applyEvents([
737
- botUpdated('test', {
738
- tags: {
739
- abc: edits(editVersion, [preserve(3), insert('123')], [preserve(9), insert('456')]),
740
- },
741
- }),
742
- ]);
743
- expect(partition.state).toEqual({
744
- test: createBot('test', {
745
- abc: 'abc123def456',
746
- }),
747
- });
748
- expect(updates.slice(1)).toEqual([
749
- stateUpdatedEvent({
750
- test: {
751
- tags: {
752
- abc: testForMergedEdits
753
- ? edits(version.vector, [
754
- preserve(3),
755
- insert('123'),
756
- preserve(3),
757
- insert('456'),
758
- ])
759
- : edits(version.vector, [preserve(3), insert('123')], [preserve(9), insert('456')]),
760
- },
761
- },
762
- }),
763
- ]);
764
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
765
- }));
766
- it('should delete tags that have all text deleted', () => __awaiter(this, void 0, void 0, function* () {
767
- yield partition.applyEvents([
768
- botAdded(createBot('test', {
769
- abc: 'abcdef',
770
- })),
771
- ]);
772
- yield waitAsync();
773
- const editVersion = Object.assign({}, version.vector);
774
- yield partition.applyEvents([
775
- botUpdated('test', {
776
- tags: {
777
- abc: edits(editVersion, [del(6)]),
778
- },
779
- }),
780
- ]);
781
- expect(partition.state).toEqual({
782
- test: createBot('test', {}),
783
- });
784
- expect(updates.slice(1)).toEqual([
785
- stateUpdatedEvent({
786
- test: {
787
- tags: {
788
- abc: edits(version.vector, [del(6)]),
789
- },
790
- },
791
- }),
792
- ]);
793
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
794
- }));
795
- const valueCases = [
796
- [
797
- 'numbers',
798
- 123,
799
- edit({}, preserve(1), insert('abc')),
800
- '1abc23',
801
- ],
802
- [
803
- 'booleans',
804
- true,
805
- edit({}, preserve(1), insert('abc')),
806
- 'tabcrue',
807
- ],
808
- [
809
- 'objects',
810
- { prop: 'yes' },
811
- edit({}, preserve(1), insert('abc')),
812
- '{abc"prop":"yes"}',
813
- ],
814
- ];
815
- it.each(valueCases)('should support %s', (desc, initial, edit, expected) => __awaiter(this, void 0, void 0, function* () {
816
- yield partition.applyEvents([
817
- botAdded(createBot('test', {
818
- abc: initial,
819
- })),
820
- ]);
821
- yield waitAsync();
822
- yield partition.applyEvents([
823
- botUpdated('test', {
824
- tags: {
825
- abc: edit,
826
- },
827
- }),
828
- ]);
829
- expect(partition.state).toEqual({
830
- test: createBot('test', {
831
- abc: expected,
832
- }),
833
- });
834
- }));
835
- it('should use a separate site ID for remote edits', () => __awaiter(this, void 0, void 0, function* () {
836
- yield partition.applyEvents([
837
- botAdded(createBot('test', {
838
- abc: 'def',
839
- })),
840
- ]);
841
- yield waitAsync();
842
- const editVersion = Object.assign({}, version.vector);
843
- const tagEdit = edit(editVersion, insert('ghi'));
844
- tagEdit.isRemote = true;
845
- yield partition.applyEvents([
846
- botUpdated('test', {
847
- tags: {
848
- abc: tagEdit,
849
- },
850
- }),
851
- ]);
852
- expect(partition.state).toEqual({
853
- test: createBot('test', {
854
- abc: 'ghidef',
855
- }),
856
- });
857
- const partitionEdit = updates[1].state.test.tags.abc;
858
- expect(partitionEdit.version).not.toEqual({
859
- [version.currentSite]: expect.any(Number),
860
- });
861
- expect(partitionEdit.version).toEqual({
862
- [version.remoteSite]: expect.any(Number),
863
- });
864
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
865
- }));
866
- if (testConcurrentEdits) {
867
- describe('concurrent edits', () => {
868
- const cases = [
869
- [
870
- 'should support concatenations',
871
- 'def',
872
- [
873
- [insert('ghi')],
874
- [preserve(3), insert('jfk')],
875
- [preserve(6), insert('lmn')],
876
- ],
877
- 'ghijfklmndef',
878
- ],
879
- [
880
- 'should support inserts',
881
- 'def',
882
- [
883
- [insert('ghi')],
884
- [preserve(1), insert('jfk')],
885
- [preserve(3), insert('lmn')],
886
- ],
887
- 'gjflmnkhidef',
888
- ],
889
- [
890
- 'should support deletes',
891
- 'def',
892
- [
893
- [insert('ghi')],
894
- [preserve(1), del(2)],
895
- [preserve(1), del(2)],
896
- ],
897
- 'gf',
898
- ],
899
- ];
900
- it.each(cases)('%s', (desc, startValue, operations, expected) => __awaiter(this, void 0, void 0, function* () {
901
- yield partition.applyEvents([
902
- botAdded(createBot('test', {
903
- abc: startValue,
904
- })),
905
- ]);
906
- yield waitAsync();
907
- const editVersion = Object.assign({}, version.vector);
908
- const edits = operations.map((ops) => edit(editVersion, ...ops));
909
- for (let e of edits) {
910
- yield partition.applyEvents([
911
- botUpdated('test', {
912
- tags: {
913
- abc: e,
914
- },
915
- }),
916
- ]);
917
- }
918
- expect(partition.state).toEqual({
919
- test: createBot('test', {
920
- abc: expected,
921
- }),
922
- });
923
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
924
- }));
925
- it('should handle concurrent inserts that rely on each other', () => __awaiter(this, void 0, void 0, function* () {
926
- yield partition.applyEvents([
927
- botAdded(createBot('test', {
928
- abc: `abc\nabc\nabc\nabc`,
929
- })),
930
- ]);
931
- yield waitAsync();
932
- const editVersion = Object.assign({}, version.vector);
933
- let edit = edits(editVersion, [preserve(3), insert('d')], [preserve(8), insert('d')], [preserve(13), insert('d')], [preserve(18), insert('d')]);
934
- yield partition.applyEvents([
935
- botUpdated('test', {
936
- tags: {
937
- abc: edit,
938
- },
939
- }),
940
- ]);
941
- expect(partition.state).toEqual({
942
- test: createBot('test', {
943
- abc: 'abcd\nabcd\nabcd\nabcd',
944
- }),
945
- });
946
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
947
- }));
948
- it('should handle local edits while remote edits occur', () => __awaiter(this, void 0, void 0, function* () {
949
- yield partition.applyEvents([
950
- botAdded(createBot('test', {
951
- abc: 'def',
952
- })),
953
- ]);
954
- yield waitAsync();
955
- const editVersion = Object.assign({}, version.vector);
956
- const edit1 = edit(editVersion, insert('111'));
957
- // after: 111def
958
- const edit2 = edit(editVersion, preserve(1), insert('222'));
959
- // after: 122211def
960
- const edit3 = edit(editVersion, preserve(2), insert('333'));
961
- // after: 122213331def
962
- const remoteEdit1 = edit(editVersion, preserve(2), insert('444'));
963
- // TODO: this is probably a bug but I want to wait on this until people
964
- // start having problems.
965
- // BUG: remote edits always see the local edits
966
- // after: 114441def
967
- edit2.isRemote = true;
968
- // final: 122213334441def
969
- yield partition.applyEvents([
970
- botUpdated('test', {
971
- tags: {
972
- abc: edit1,
973
- },
974
- }),
975
- ]);
976
- yield partition.applyEvents([
977
- botUpdated('test', {
978
- tags: {
979
- abc: remoteEdit1,
980
- },
981
- }),
982
- ]);
983
- yield partition.applyEvents([
984
- botUpdated('test', {
985
- tags: {
986
- abc: edit2,
987
- },
988
- }),
989
- ]);
990
- yield partition.applyEvents([
991
- botUpdated('test', {
992
- tags: {
993
- abc: edit3,
994
- },
995
- }),
996
- ]);
997
- expect(partition.state).toEqual({
998
- test: createBot('test', {
999
- abc: '122213334441def',
1000
- }),
1001
- });
1002
- }));
1003
- });
1004
- describe('fuzzing', () => {
1005
- faker.seed(95423);
1006
- const randomEdits = generateRandomEditCases(25);
1007
- const paragraphCases = generateRandomEditParagraphCases(5);
1008
- describe.each([...randomEdits, ...paragraphCases])('%s -> %s', (startText, endText, intermediateTexts, edits) => {
1009
- const space = 'space';
1010
- it('should be able to apply the given edits to produce the final text', () => __awaiter(this, void 0, void 0, function* () {
1011
- yield partition.applyEvents([
1012
- botAdded(createBot('test', {
1013
- abc: startText,
1014
- })),
1015
- ]);
1016
- for (let i = 0; i < edits.length; i++) {
1017
- let edit = edits[i];
1018
- let str = intermediateTexts[i];
1019
- yield partition.applyEvents([
1020
- botUpdated('test', {
1021
- tags: {
1022
- abc: edit,
1023
- },
1024
- }),
1025
- ]);
1026
- expect(partition.state).toEqual({
1027
- test: createBot('test', hasValue(str)
1028
- ? {
1029
- abc: str,
1030
- }
1031
- : {}),
1032
- });
1033
- }
1034
- expect(partition.state).toEqual({
1035
- test: createBot('test', hasValue(endText)
1036
- ? {
1037
- abc: endText,
1038
- }
1039
- : {}),
1040
- });
1041
- }));
1042
- it('should be able to apply the given edit to tag masks', () => __awaiter(this, void 0, void 0, function* () {
1043
- partition.space = space;
1044
- yield partition.applyEvents([
1045
- botUpdated('test', {
1046
- masks: {
1047
- [space]: {
1048
- abc: startText,
1049
- },
1050
- },
1051
- }),
1052
- ]);
1053
- for (let i = 0; i < edits.length; i++) {
1054
- let edit = edits[i];
1055
- let str = intermediateTexts[i];
1056
- yield partition.applyEvents([
1057
- botUpdated('test', {
1058
- masks: {
1059
- [space]: {
1060
- abc: edit,
1061
- },
1062
- },
1063
- }),
1064
- ]);
1065
- expect(partition.state).toEqual({
1066
- test: hasValue(str)
1067
- ? {
1068
- masks: {
1069
- [space]: {
1070
- abc: str,
1071
- },
1072
- },
1073
- }
1074
- : {},
1075
- });
1076
- }
1077
- expect(partition.state).toEqual({
1078
- test: hasValue(endText)
1079
- ? {
1080
- masks: {
1081
- [space]: {
1082
- abc: endText,
1083
- },
1084
- },
1085
- }
1086
- : {},
1087
- });
1088
- }));
1089
- });
1090
- });
1091
- }
1092
- });
1093
- describe('TagMasks', () => {
1094
- beforeEach(() => {
1095
- partition.space = 'testSpace';
1096
- });
1097
- it('should support tag mask updates for the partition space', () => __awaiter(this, void 0, void 0, function* () {
1098
- yield partition.applyEvents([
1099
- botUpdated('test', {
1100
- masks: {
1101
- [partition.space]: {
1102
- newTag: true,
1103
- abc: 123,
1104
- },
1105
- },
1106
- }),
1107
- ]);
1108
- yield waitAsync();
1109
- expect(partition.state).toEqual({
1110
- test: {
1111
- masks: {
1112
- [partition.space]: {
1113
- newTag: true,
1114
- abc: 123,
1115
- },
1116
- },
1117
- },
1118
- });
1119
- expect(updated).toEqual([]);
1120
- expect(updates).toEqual([
1121
- {
1122
- state: {
1123
- test: {
1124
- masks: {
1125
- [partition.space]: {
1126
- newTag: true,
1127
- abc: 123,
1128
- },
1129
- },
1130
- },
1131
- },
1132
- addedBots: [],
1133
- removedBots: [],
1134
- updatedBots: ['test'],
1135
- },
1136
- ]);
1137
- }));
1138
- it('should support tag mask updates on multiple bots at a time', () => __awaiter(this, void 0, void 0, function* () {
1139
- yield partition.applyEvents([
1140
- botUpdated('test1', {
1141
- masks: {
1142
- [partition.space]: {
1143
- newTag: true,
1144
- abc: 123,
1145
- },
1146
- },
1147
- }),
1148
- botUpdated('test2', {
1149
- masks: {
1150
- [partition.space]: {
1151
- otherTag: true,
1152
- num: 123,
1153
- },
1154
- },
1155
- }),
1156
- ]);
1157
- yield waitAsync();
1158
- expect(partition.state).toEqual({
1159
- test1: {
1160
- masks: {
1161
- [partition.space]: {
1162
- newTag: true,
1163
- abc: 123,
1164
- },
1165
- },
1166
- },
1167
- test2: {
1168
- masks: {
1169
- [partition.space]: {
1170
- otherTag: true,
1171
- num: 123,
1172
- },
1173
- },
1174
- },
1175
- });
1176
- expect(updated).toEqual([]);
1177
- expect(updates).toEqual([
1178
- {
1179
- state: {
1180
- test1: {
1181
- masks: {
1182
- [partition.space]: {
1183
- newTag: true,
1184
- abc: 123,
1185
- },
1186
- },
1187
- },
1188
- test2: {
1189
- masks: {
1190
- [partition.space]: {
1191
- otherTag: true,
1192
- num: 123,
1193
- },
1194
- },
1195
- },
1196
- },
1197
- addedBots: [],
1198
- removedBots: [],
1199
- updatedBots: ['test1', 'test2'],
1200
- },
1201
- ]);
1202
- }));
1203
- it('should ignore tag mask updates for different partition spaces', () => __awaiter(this, void 0, void 0, function* () {
1204
- yield partition.applyEvents([
1205
- botUpdated('test', {
1206
- masks: {
1207
- ['different']: {
1208
- newTag: true,
1209
- abc: 123,
1210
- },
1211
- },
1212
- }),
1213
- ]);
1214
- yield waitAsync();
1215
- expect(partition.state).toEqual({});
1216
- expect(updated).toEqual([]);
1217
- expect(updates).toEqual([]);
1218
- }));
1219
- it('should support tag mask updates for bots in the same partition', () => __awaiter(this, void 0, void 0, function* () {
1220
- yield partition.applyEvents([
1221
- botAdded(createBot('test', {
1222
- abc: 'def',
1223
- })),
1224
- ]);
1225
- yield partition.applyEvents([
1226
- botUpdated('test', {
1227
- masks: {
1228
- [partition.space]: {
1229
- newTag: true,
1230
- abc: 123,
1231
- },
1232
- },
1233
- }),
1234
- ]);
1235
- yield waitAsync();
1236
- expect(partition.state).toEqual({
1237
- test: {
1238
- id: 'test',
1239
- space: partition.space,
1240
- tags: {
1241
- abc: 'def',
1242
- },
1243
- masks: {
1244
- [partition.space]: {
1245
- newTag: true,
1246
- abc: 123,
1247
- },
1248
- },
1249
- },
1250
- });
1251
- expect(updated).toEqual([]);
1252
- expect(updates.slice(1)).toEqual([
1253
- {
1254
- state: {
1255
- test: {
1256
- masks: {
1257
- [partition.space]: {
1258
- newTag: true,
1259
- abc: 123,
1260
- },
1261
- },
1262
- },
1263
- },
1264
- addedBots: [],
1265
- removedBots: [],
1266
- updatedBots: ['test'],
1267
- },
1268
- ]);
1269
- }));
1270
- it('should not confuse tag masks and tags when given an empty tags object in an update', () => __awaiter(this, void 0, void 0, function* () {
1271
- yield partition.applyEvents([
1272
- botUpdated('test', {
1273
- tags: {},
1274
- masks: {
1275
- [partition.space]: {
1276
- newTag: true,
1277
- },
1278
- },
1279
- }),
1280
- ]);
1281
- yield waitAsync();
1282
- expect(partition.state).toEqual({
1283
- test: {
1284
- masks: {
1285
- [partition.space]: {
1286
- newTag: true,
1287
- },
1288
- },
1289
- },
1290
- });
1291
- expect(updated).toEqual([]);
1292
- expect(updates).toEqual([
1293
- {
1294
- state: {
1295
- test: {
1296
- masks: {
1297
- [partition.space]: {
1298
- newTag: true,
1299
- },
1300
- },
1301
- },
1302
- },
1303
- addedBots: [],
1304
- removedBots: [],
1305
- updatedBots: ['test'],
1306
- },
1307
- ]);
1308
- }));
1309
- describe('edits', () => {
1310
- it('should support inserting text into a tag mask value', () => __awaiter(this, void 0, void 0, function* () {
1311
- yield partition.applyEvents([
1312
- botUpdated('test', {
1313
- masks: {
1314
- testSpace: {
1315
- abc: 'def',
1316
- },
1317
- },
1318
- }),
1319
- ]);
1320
- yield waitAsync();
1321
- yield partition.applyEvents([
1322
- botUpdated('test', {
1323
- masks: {
1324
- testSpace: {
1325
- abc: edit(version.vector, insert('ghi')),
1326
- },
1327
- },
1328
- }),
1329
- ]);
1330
- yield waitAsync();
1331
- expect(partition.state).toEqual({
1332
- test: {
1333
- masks: {
1334
- testSpace: {
1335
- abc: 'ghidef',
1336
- },
1337
- },
1338
- },
1339
- });
1340
- expect(updated).toEqual([]);
1341
- expect(updates.slice(1)).toEqual([
1342
- stateUpdatedEvent({
1343
- test: {
1344
- masks: {
1345
- testSpace: {
1346
- abc: edit(version.vector, insert('ghi')),
1347
- },
1348
- },
1349
- },
1350
- }),
1351
- ]);
1352
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
1353
- }));
1354
- it('should support deleting text from a tag mask value', () => __awaiter(this, void 0, void 0, function* () {
1355
- yield partition.applyEvents([
1356
- botUpdated('test', {
1357
- masks: {
1358
- testSpace: {
1359
- abc: 'def',
1360
- },
1361
- },
1362
- }),
1363
- ]);
1364
- yield waitAsync();
1365
- yield partition.applyEvents([
1366
- botUpdated('test', {
1367
- masks: {
1368
- testSpace: {
1369
- abc: edit(version.vector, del(2)),
1370
- },
1371
- },
1372
- }),
1373
- ]);
1374
- yield waitAsync();
1375
- expect(partition.state).toEqual({
1376
- test: {
1377
- masks: {
1378
- testSpace: {
1379
- abc: 'f',
1380
- },
1381
- },
1382
- },
1383
- });
1384
- expect(updated).toEqual([]);
1385
- expect(updates.slice(1)).toEqual([
1386
- stateUpdatedEvent({
1387
- test: {
1388
- masks: {
1389
- testSpace: {
1390
- abc: edit(version.vector, del(2)),
1391
- },
1392
- },
1393
- },
1394
- }),
1395
- ]);
1396
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
1397
- }));
1398
- it('should delete tag masks that have all text deleted', () => __awaiter(this, void 0, void 0, function* () {
1399
- yield partition.applyEvents([
1400
- botUpdated('test', {
1401
- masks: {
1402
- [partition.space]: {
1403
- newTag: 'value',
1404
- },
1405
- },
1406
- }),
1407
- ]);
1408
- yield waitAsync();
1409
- const editVersion = Object.assign({}, version.vector);
1410
- yield partition.applyEvents([
1411
- botUpdated('test', {
1412
- masks: {
1413
- [partition.space]: {
1414
- newTag: edits(editVersion, [del(5)]),
1415
- },
1416
- },
1417
- }),
1418
- ]);
1419
- expect(partition.state).toEqual({
1420
- test: {},
1421
- });
1422
- expect(updates.slice(1)).toEqual([
1423
- stateUpdatedEvent({
1424
- test: {
1425
- masks: {
1426
- [partition.space]: {
1427
- newTag: edits(version.vector, [del(5)]),
1428
- },
1429
- },
1430
- },
1431
- }),
1432
- ]);
1433
- expect(Object.keys(version.vector).length).toBeGreaterThan(0);
1434
- }));
1435
- });
1436
- });
1437
- });
1438
- describe('apply_state', () => {
1439
- it('should be able to add a bot to the partition', () => __awaiter(this, void 0, void 0, function* () {
1440
- const bot = createBot('test', {
1441
- abc: 'def',
1442
- });
1443
- yield partition.applyEvents([
1444
- {
1445
- type: 'apply_state',
1446
- state: {
1447
- test: bot,
1448
- },
1449
- },
1450
- ]);
1451
- yield waitAsync();
1452
- expect(added).toEqual([bot]);
1453
- }));
1454
- it('should be able to update a bot in the partition', () => __awaiter(this, void 0, void 0, function* () {
1455
- const bot = createBot('test', {
1456
- abc: 'def',
1457
- });
1458
- // Run the bot added and updated
1459
- // events in separate batches
1460
- // because partitions may combine the events
1461
- yield partition.applyEvents([botAdded(bot)]);
1462
- yield partition.applyEvents([
1463
- {
1464
- type: 'apply_state',
1465
- state: {
1466
- test: {
1467
- tags: {
1468
- abc: 'ghi',
1469
- },
1470
- },
1471
- },
1472
- },
1473
- ]);
1474
- yield waitAsync();
1475
- expect(updated).toEqual([
1476
- {
1477
- bot: createBot('test', {
1478
- abc: 'ghi',
1479
- }),
1480
- tags: ['abc'],
1481
- },
1482
- ]);
1483
- }));
1484
- it('should be able to delete a bot in the partition', () => __awaiter(this, void 0, void 0, function* () {
1485
- const bot = createBot('test', {
1486
- abc: 'def',
1487
- });
1488
- // Run the bot added and updated
1489
- // events in separate batches
1490
- // because partitions may combine the events
1491
- yield partition.applyEvents([botAdded(bot)]);
1492
- yield partition.applyEvents([
1493
- {
1494
- type: 'apply_state',
1495
- state: {
1496
- test: null,
1497
- },
1498
- },
1499
- ]);
1500
- yield waitAsync();
1501
- expect(removed).toEqual(['test']);
1502
- }));
1503
- });
1504
- describe('getPartitionState()', () => {
1505
- it('should be able to get the state from the partition', () => __awaiter(this, void 0, void 0, function* () {
1506
- const bot1 = createBot('test', {
1507
- abc: 'def',
1508
- });
1509
- const bot2 = createBot('test2', {
1510
- abc: 'xyz',
1511
- });
1512
- yield partition.applyEvents([botAdded(bot1), botAdded(bot2)]);
1513
- const state = getPartitionState(partition);
1514
- expect(state).toEqual({
1515
- test: bot1,
1516
- test2: bot2,
1517
- });
1518
- }));
1519
- });
1520
- describe('connect()', () => {
1521
- it('should issue connection, authentication, authorization, and sync events in that order', () => __awaiter(this, void 0, void 0, function* () {
1522
- const promise = partition.onStatusUpdated
1523
- .pipe(takeWhile((update) => update.type !== 'sync', true), bufferCount(4))
1524
- .toPromise();
1525
- partition.connect();
1526
- const update = yield promise;
1527
- expect(update).toEqual([
1528
- {
1529
- type: 'connection',
1530
- connected: true,
1531
- },
1532
- expect.objectContaining({
1533
- type: 'authentication',
1534
- authenticated: true,
1535
- }),
1536
- expect.objectContaining({
1537
- type: 'authorization',
1538
- authorized: true,
1539
- }),
1540
- {
1541
- type: 'sync',
1542
- synced: true,
1543
- },
1544
- ]);
1545
- }));
1546
- });
1547
- }
1548
- //# sourceMappingURL=PartitionTests.js.map