@instantdb/core 0.22.86-experimental.split-store.20247691802.1 → 0.22.86-experimental.split-store.20249702529.1

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.
@@ -64,8 +64,13 @@ function checkIndexIntegrity({
64
64
  const aevTriples = allMapValues(store.aev, 3).sort(tripleSort);
65
65
  const vaeTriples = allMapValues(store.vae, 3);
66
66
 
67
- // Check eav and aev have all the same values
68
- expect(eavTriples).toEqual(aevTriples);
67
+ // Check eav and aev have all the same triples
68
+ for (let i = 0; i < eavTriples.length; i++) {
69
+ const et = eavTriples[i];
70
+ const at = aevTriples[i];
71
+ expect(et).toEqual(at);
72
+ }
73
+ expect(eavTriples.length).toEqual(aevTriples.length);
69
74
 
70
75
  // Check vae doesn't have extra triples
71
76
  for (const triple of vaeTriples) {
@@ -512,6 +517,8 @@ test('deepMerge', () => {
512
517
  ),
513
518
  );
514
519
 
520
+ checkIndexIntegrity(gameCtx);
521
+
515
522
  const updatedCtx = transact(
516
523
  gameCtx.store,
517
524
  gameCtx.attrsStore,
@@ -537,6 +544,7 @@ test('deepMerge', () => {
537
544
  }),
538
545
  ),
539
546
  );
547
+
540
548
  const updatedGame = query(updatedCtx, {
541
549
  games: { $: { where: { id: gameId } } },
542
550
  }).data.games[0];
@@ -551,8 +559,7 @@ test('deepMerge', () => {
551
559
  inventory: ['shield'],
552
560
  locations: ['forest', undefined, 'castle'],
553
561
  });
554
- // XXXX: Why does this fail??
555
- //checkIndexIntegrity(updatedCtx);
562
+ checkIndexIntegrity(updatedCtx);
556
563
  });
557
564
 
558
565
  test('recursive links w same id', () => {
@@ -792,7 +792,7 @@ class Reactor {
792
792
  }
793
793
  }
794
794
  if (newAttrs.length) {
795
- const existingAttrs = Object.values(this.ensureAttrs());
795
+ const existingAttrs = Object.values(this.ensureAttrs().attrs);
796
796
  this._setAttrs([...existingAttrs, ...newAttrs]);
797
797
  this._setAttrs(newAttrs);
798
798
  }
@@ -1600,7 +1600,7 @@ class Reactor {
1600
1600
  if (!this.attrs)
1601
1601
  return;
1602
1602
  const oas = this.optimisticAttrs();
1603
- this.attrsCbs.forEach((cb) => cb(oas));
1603
+ this.attrsCbs.forEach((cb) => cb(oas.attrs));
1604
1604
  }
1605
1605
  notifyConnectionStatusSubs(status) {
1606
1606
  this.connectionStatusCbs.forEach((cb) => cb(status));