@arrai-innovations/reactive-helpers 14.0.2 → 15.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.
@@ -3,7 +3,8 @@ import { expectErrorToBeNull } from "../expectHelpers.js";
3
3
  import flushPromises from "flush-promises";
4
4
  import keyBy from "lodash-es/keyBy.js";
5
5
  import { inspect } from "util";
6
- import { isReactive, nextTick, reactive, isRef, isReadonly } from "vue";
6
+ import { isReactive, nextTick, reactive, isRef, isReadonly, ref } from "vue";
7
+ import { ListInstanceError } from "../../../use/listInstance.js";
7
8
 
8
9
  afterAll(() => {
9
10
  vi.restoreAllMocks();
@@ -11,17 +12,19 @@ afterAll(() => {
11
12
 
12
13
  const fields = ["id", "__str__", "name"];
13
14
  describe("use/listInstance.spec.js", function () {
14
- let useListInstance, ListInstanceError, useListInstances, globalList, globalbulkDelete;
15
+ let useListInstance, ListInstanceError, useListInstances, globalList, globalbulkDelete, globalexecuteAction;
15
16
  beforeEach(async () => {
16
17
  const listCrud = await import("../../../config/listCrud.js");
17
18
  const imported = await import("../../../use/listInstance.js");
18
19
  globalList = vi.fn();
19
20
  globalbulkDelete = vi.fn(() => Promise.resolve(true));
21
+ globalexecuteAction = vi.fn(() => Promise.resolve(true));
20
22
  // @ts-ignore
21
23
  globalList.cancel = vi.fn();
22
24
  listCrud.setListCrud({
23
25
  list: globalList,
24
26
  bulkDelete: globalbulkDelete,
27
+ executeAction: globalexecuteAction,
25
28
  args: { stream: "test_stream" },
26
29
  });
27
30
  useListInstance = imported.useListInstance;
@@ -98,7 +101,10 @@ describe("use/listInstance.spec.js", function () {
98
101
  const retrieveArgs = reactive({
99
102
  fields,
100
103
  });
101
- const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
104
+ const listInstance = useListInstance({
105
+ props: { pkKey: "id", listArgs, retrieveArgs },
106
+ keepOldPages: false,
107
+ });
102
108
  let crudListResolve;
103
109
  const crudListPromise = new Promise((resolve) => {
104
110
  crudListResolve = resolve;
@@ -165,7 +171,10 @@ describe("use/listInstance.spec.js", function () {
165
171
  const retrieveArgs = reactive({
166
172
  fields,
167
173
  });
168
- const listInstance = useListInstance({ props: { pkKey: "unique", listArgs, retrieveArgs } });
174
+ const listInstance = useListInstance({
175
+ props: { pkKey: "unique", listArgs, retrieveArgs },
176
+ keepOldPages: false,
177
+ });
169
178
  let crudListResolve;
170
179
  const crudListPromise = new Promise((resolve) => {
171
180
  crudListResolve = resolve;
@@ -207,14 +216,17 @@ describe("use/listInstance.spec.js", function () {
207
216
  });
208
217
  expect(globalList).toHaveBeenCalledTimes(1);
209
218
  });
210
- it("already loading", async function () {
219
+ it("already retrieving", async function () {
211
220
  const listArgs = reactive({
212
221
  user: 1,
213
222
  });
214
223
  const retrieveArgs = reactive({
215
224
  fields,
216
225
  });
217
- const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
226
+ const listInstance = useListInstance({
227
+ props: { pkKey: "id", listArgs, retrieveArgs, keepOldPages: false },
228
+ keepOldPages: false,
229
+ });
218
230
  expectErrorToBeNull(listInstance.state.error);
219
231
  expect(listInstance.state.errored).toBe(false);
220
232
  expect(listInstance.state.loading).toBeUndefined();
@@ -238,6 +250,32 @@ describe("use/listInstance.spec.js", function () {
238
250
  expect(listInstance.state.loading).toBe(true);
239
251
  expect({ ...listInstance.state.objects }).toEqual({});
240
252
  });
253
+ it("already loading", async function () {
254
+ const listArgs = reactive({
255
+ user: 1,
256
+ });
257
+ const retrieveArgs = reactive({
258
+ fields,
259
+ });
260
+ const listInstance = useListInstance({
261
+ props: { pkKey: "id", listArgs, retrieveArgs },
262
+ keepOldPages: false,
263
+ });
264
+ expectErrorToBeNull(listInstance.state.error);
265
+ expect(listInstance.state.errored).toBe(false);
266
+ expect(listInstance.state.loading).toBeUndefined();
267
+ expect({ ...listInstance.state.objects }).toEqual({});
268
+ globalList.mockImplementation(() => new Promise(() => {}));
269
+ listInstance.bulkDelete();
270
+
271
+ expectErrorToBeNull(listInstance.state.error);
272
+ expect(listInstance.state.errored).toBe(false);
273
+ expect(listInstance.state.loading).toBe(true);
274
+ await expect(() => listInstance.list()).rejects.toThrow(ListInstanceError);
275
+ expectErrorToBeNull(listInstance.state.error);
276
+ expect(listInstance.state.errored).toBe(false);
277
+ expect(listInstance.state.loading).toBe(true);
278
+ });
241
279
  it("errored", async function () {
242
280
  const listArgs = reactive({
243
281
  user: 1,
@@ -245,7 +283,10 @@ describe("use/listInstance.spec.js", function () {
245
283
  const retrieveArgs = reactive({
246
284
  fields,
247
285
  });
248
- const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
286
+ const listInstance = useListInstance({
287
+ props: { pkKey: "id", listArgs, retrieveArgs },
288
+ keepOldPages: false,
289
+ });
249
290
  let crudListReject;
250
291
  const crudListPromise = new Promise((resolve, reject) => {
251
292
  crudListReject = reject;
@@ -300,6 +341,7 @@ describe("use/listInstance.spec.js", function () {
300
341
  });
301
342
  const listInstance = useListInstance({
302
343
  props: { pkKey: "id", listArgs, retrieveArgs, crudArgs: { stream: "custom_stream" } },
344
+ keepOldPages: false,
303
345
  });
304
346
  let crudListResolve;
305
347
  const crudListPromise = new Promise((resolve) => {
@@ -374,6 +416,7 @@ describe("use/listInstance.spec.js", function () {
374
416
  retrieveArgs,
375
417
  pkKey: "id",
376
418
  },
419
+ keepOldPages: false,
377
420
  });
378
421
  let crudListResolve;
379
422
  const crudListPromise = new Promise((resolve) => {
@@ -433,6 +476,7 @@ describe("use/listInstance.spec.js", function () {
433
476
  fields,
434
477
  },
435
478
  },
479
+ keepOldPages: false,
436
480
  });
437
481
  const listInstanceB = useListInstance({
438
482
  props: {
@@ -443,6 +487,7 @@ describe("use/listInstance.spec.js", function () {
443
487
  fields,
444
488
  },
445
489
  },
490
+ keepOldPages: false,
446
491
  });
447
492
  const listInstances = useListInstances({
448
493
  A: {
@@ -454,6 +499,7 @@ describe("use/listInstance.spec.js", function () {
454
499
  fields,
455
500
  },
456
501
  },
502
+ keepOldPages: false,
457
503
  },
458
504
  B: {
459
505
  props: {
@@ -464,6 +510,7 @@ describe("use/listInstance.spec.js", function () {
464
510
  fields,
465
511
  },
466
512
  },
513
+ keepOldPages: false,
467
514
  },
468
515
  });
469
516
  expect(inspect(listInstances.A)).toEqual(inspect(listInstanceA));
@@ -471,14 +518,14 @@ describe("use/listInstance.spec.js", function () {
471
518
  });
472
519
  describe("addListObject", function () {
473
520
  it("errored", function () {
474
- const listInstance = useListInstance({ props: { pkKey: "id" } });
521
+ const listInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
475
522
  expect(() => listInstance.addListObject({ listObject })).toThrowError(ListInstanceError);
476
523
  listObject.id = listInstance.getFakePk();
477
524
  listInstance.addListObject(listObject);
478
525
  expect(() => listInstance.addListObject({ listObject })).toThrowError(ListInstanceError);
479
526
  });
480
527
  it("succeeded", async function () {
481
- const listInstance = useListInstance({ props: { pkKey: "id" } });
528
+ const listInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
482
529
  const newId = listInstance.getFakePk();
483
530
  listObject.id = newId;
484
531
  listInstance.addListObject(listObject);
@@ -501,7 +548,7 @@ describe("use/listInstance.spec.js", function () {
501
548
  });
502
549
  describe("updateListObject", function () {
503
550
  it("errors", function () {
504
- const listInstance = useListInstance({ props: { pkKey: "id" } });
551
+ const listInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
505
552
  expect(() => listInstance.updateListObject({ listObject })).toThrowError(ListInstanceError);
506
553
  listObject.id = -50002000;
507
554
  listInstance.addListObject(listObject);
@@ -510,6 +557,7 @@ describe("use/listInstance.spec.js", function () {
510
557
  it("succeeds", async function () {
511
558
  const listInstance = useListInstance({
512
559
  props: { pkKey: "id" },
560
+ keepOldPages: false,
513
561
  });
514
562
  let crudListResolve;
515
563
  const crudListPromise = new Promise((resolve) => {
@@ -546,12 +594,13 @@ describe("use/listInstance.spec.js", function () {
546
594
  });
547
595
  describe("deleteListObject", function () {
548
596
  it("errors", function () {
549
- const listInstance = useListInstance({ props: { pkKey: "id" } });
597
+ const listInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
550
598
  expect(() => listInstance.deleteListObject(-50002000)).toThrowError(ListInstanceError);
551
599
  });
552
600
  it("succeeds", async function () {
553
601
  const listInstance = useListInstance({
554
602
  props: { pkKey: "id" },
603
+ keepOldPages: false,
555
604
  });
556
605
  let crudListResolve;
557
606
  const crudListPromise = new Promise((resolve) => {
@@ -591,6 +640,182 @@ describe("use/listInstance.spec.js", function () {
591
640
  expect(listInstance.state.order).toEqual(["2", "3"]);
592
641
  });
593
642
  });
643
+ describe("executeAction", function () {
644
+ it("succeeds", async function () {
645
+ const listArgs = reactive({
646
+ user: 1,
647
+ });
648
+ const retrieveArgs = reactive({
649
+ fields,
650
+ });
651
+ const listInstance = useListInstance({
652
+ props: { pkKey: "id", listArgs, retrieveArgs },
653
+ keepOldPages: false,
654
+ });
655
+ let crudListResolve;
656
+ const crudListPromise = new Promise((resolve) => {
657
+ crudListResolve = resolve;
658
+ });
659
+ let passedPageCallback;
660
+ globalList.mockImplementation(({ pageCallback }) => {
661
+ passedPageCallback = pageCallback;
662
+ return crudListPromise;
663
+ });
664
+ const liListResolve = listInstance.list();
665
+ await nextTick();
666
+ // @ts-ignore - pageCallback is set in the mock, if not it will throw which is what we want
667
+ passedPageCallback(crudListResolvedPage2);
668
+ // @ts-ignore - crudListResolve is set in a promise, since we await this will be set
669
+ crudListResolve();
670
+ await flushPromises();
671
+ await expect(liListResolve).resolves.toBe(true);
672
+
673
+ expect({ ...listInstance.state.objects }).toEqual(crudListResolvedObjects2);
674
+ const executeActionResolve = listInstance.executeAction();
675
+ expectErrorToBeNull(listInstance.state.error);
676
+ expect(listInstance.state.errored).toBe(false);
677
+ expect(listInstance.state.loading).toBe(true);
678
+ expect(globalexecuteAction).toHaveBeenCalledWith({
679
+ crudArgs: { stream: "test_stream" },
680
+ pkKey: "id",
681
+ pks: Object.keys(crudListResolvedObjects2).map(Number),
682
+ });
683
+
684
+ expect(globalexecuteAction).toHaveBeenCalledTimes(1);
685
+
686
+ // @ts-ignore - executeAction is set in a promise, since we await this will be set
687
+ crudListResolve();
688
+ await flushPromises();
689
+ await expect(executeActionResolve).resolves.toBe(true);
690
+ expect({ ...listInstance.state.objects }).toEqual({});
691
+ });
692
+ it("succeeds with non-standard primary key", async function () {
693
+ const listArgs = reactive({
694
+ user: 1,
695
+ });
696
+ const retrieveArgs = reactive({
697
+ fields,
698
+ });
699
+ const listInstance = useListInstance({
700
+ props: { pkKey: "unique", listArgs, retrieveArgs },
701
+ keepOldPages: false,
702
+ });
703
+ let crudListResolve;
704
+ const crudListPromise = new Promise((resolve) => {
705
+ crudListResolve = resolve;
706
+ });
707
+ let passedPageCallback;
708
+ globalList.mockImplementation(({ pageCallback }) => {
709
+ passedPageCallback = pageCallback;
710
+ return crudListPromise;
711
+ });
712
+ const liListResolve = listInstance.list();
713
+ await nextTick();
714
+ // @ts-ignore - pageCallback is set in the mock, if not it will throw which is what we want
715
+ passedPageCallback(crudListResolvedPageNonStandardPK);
716
+ // @ts-ignore - crudListResolve is set in a promise, since we await this will be set
717
+ crudListResolve();
718
+ await flushPromises();
719
+ await expect(liListResolve).resolves.toBe(true);
720
+
721
+ expect({ ...listInstance.state.objects }).toEqual(crudListResolvedObjectsNonStandardPK);
722
+ const executeActionResolve = listInstance.executeAction();
723
+ expectErrorToBeNull(listInstance.state.error);
724
+ expect(listInstance.state.errored).toBe(false);
725
+ expect(listInstance.state.loading).toBe(true);
726
+ expect(globalexecuteAction).toHaveBeenCalledWith({
727
+ crudArgs: { stream: "test_stream" },
728
+ pkKey: "unique",
729
+ pks: Object.keys(crudListResolvedObjectsNonStandardPK).map(Number),
730
+ });
731
+
732
+ expect(globalexecuteAction).toHaveBeenCalledTimes(1);
733
+
734
+ // @ts-ignore - globalexecuteAction is set in a promise, since we await this will be set
735
+ crudListResolve();
736
+ await flushPromises();
737
+ await expect(executeActionResolve).resolves.toBe(true);
738
+ expect({ ...listInstance.state.objects }).toEqual({});
739
+ });
740
+ it("already loading", async function () {
741
+ const listArgs = reactive({
742
+ user: 1,
743
+ });
744
+ const retrieveArgs = reactive({
745
+ fields,
746
+ });
747
+ const listInstance = useListInstance({
748
+ props: { pkKey: "id", listArgs, retrieveArgs },
749
+ keepOldPages: false,
750
+ });
751
+ expectErrorToBeNull(listInstance.state.error);
752
+ expect(listInstance.state.errored).toBe(false);
753
+ expect(listInstance.state.loading).toBeUndefined();
754
+ expect({ ...listInstance.state.objects }).toEqual({});
755
+ globalexecuteAction.mockImplementation(() => new Promise(() => {}));
756
+ listInstance.executeAction();
757
+ expectErrorToBeNull(listInstance.state.error);
758
+ expect(listInstance.state.errored).toBe(false);
759
+ expect(listInstance.state.loading).toBe(true);
760
+ await expect(() => listInstance.executeAction()).rejects.toThrow(ListInstanceError);
761
+ expectErrorToBeNull(listInstance.state.error);
762
+ expect(listInstance.state.errored).toBe(false);
763
+ expect(listInstance.state.loading).toBe(true);
764
+ });
765
+ it("errored", async function () {
766
+ const listArgs = reactive({
767
+ user: 1,
768
+ });
769
+ const retrieveArgs = reactive({
770
+ fields,
771
+ });
772
+ const listInstance = useListInstance({
773
+ props: { pkKey: "id", listArgs, retrieveArgs },
774
+ keepOldPages: false,
775
+ });
776
+ let crudListReject;
777
+ const crudListPromise = new Promise((resolve, reject) => {
778
+ crudListReject = reject;
779
+ });
780
+ let passedPageCallback;
781
+ globalexecuteAction.mockImplementation(({ pageCallback }) => {
782
+ passedPageCallback = pageCallback;
783
+ return crudListPromise;
784
+ });
785
+
786
+ expectErrorToBeNull(listInstance.state.error);
787
+ expect(listInstance.state.errored).toBe(false);
788
+ expect(listInstance.state.loading).toBeUndefined();
789
+ expect({ ...listInstance.state.objects }).toEqual({});
790
+
791
+ const liListResolve = listInstance.executeAction();
792
+
793
+ expectErrorToBeNull(listInstance.state.error);
794
+ expect(listInstance.state.errored).toBe(false);
795
+ expect(listInstance.state.loading).toBe(true);
796
+ expect({ ...listInstance.state.objects }).toEqual({});
797
+
798
+ await nextTick();
799
+
800
+ const rejected = new Error("Test Error");
801
+ // @ts-ignore - crudListReject is set in a promise, since we await this will be set
802
+ crudListReject(rejected);
803
+ await flushPromises();
804
+
805
+ await expect(liListResolve).resolves.toBe(false);
806
+
807
+ expect(listInstance.state.error).toBe(rejected);
808
+ expect(listInstance.state.errored).toBe(true);
809
+ expect(listInstance.state.loading).toBe(false);
810
+ expect({ ...listInstance.state.objects }).toEqual({});
811
+ expect(globalexecuteAction).toHaveBeenCalledWith({
812
+ crudArgs: { stream: "test_stream" },
813
+ pkKey: "id",
814
+ pks: [],
815
+ });
816
+ expect(globalexecuteAction).toHaveBeenCalledTimes(1);
817
+ });
818
+ });
594
819
  describe("bulkDelete", function () {
595
820
  it("succeeds", async function () {
596
821
  const listArgs = reactive({
@@ -599,7 +824,10 @@ describe("use/listInstance.spec.js", function () {
599
824
  const retrieveArgs = reactive({
600
825
  fields,
601
826
  });
602
- const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
827
+ const listInstance = useListInstance({
828
+ props: { pkKey: "id", listArgs, retrieveArgs },
829
+ keepOldPages: false,
830
+ });
603
831
  let crudListResolve;
604
832
  const crudListPromise = new Promise((resolve) => {
605
833
  crudListResolve = resolve;
@@ -644,7 +872,10 @@ describe("use/listInstance.spec.js", function () {
644
872
  const retrieveArgs = reactive({
645
873
  fields,
646
874
  });
647
- const listInstance = useListInstance({ props: { pkKey: "unique", listArgs, retrieveArgs } });
875
+ const listInstance = useListInstance({
876
+ props: { pkKey: "unique", listArgs, retrieveArgs },
877
+ keepOldPages: false,
878
+ });
648
879
  let crudListResolve;
649
880
  const crudListPromise = new Promise((resolve) => {
650
881
  crudListResolve = resolve;
@@ -682,10 +913,91 @@ describe("use/listInstance.spec.js", function () {
682
913
  await expect(bulkDeleteResolve).resolves.toBe(true);
683
914
  expect({ ...listInstance.state.objects }).toEqual({});
684
915
  });
916
+ it("already loading", async function () {
917
+ const listArgs = reactive({
918
+ user: 1,
919
+ });
920
+ const retrieveArgs = reactive({
921
+ fields,
922
+ });
923
+ const listInstance = useListInstance({
924
+ props: { pkKey: "id", listArgs, retrieveArgs },
925
+ keepOldPages: false,
926
+ });
927
+ expectErrorToBeNull(listInstance.state.error);
928
+ expect(listInstance.state.errored).toBe(false);
929
+ expect(listInstance.state.loading).toBeUndefined();
930
+ expect({ ...listInstance.state.objects }).toEqual({});
931
+ globalbulkDelete.mockImplementation(() => new Promise(() => {}));
932
+ expectErrorToBeNull(listInstance.state.error);
933
+ expect(listInstance.state.errored).toBe(false);
934
+ expect(listInstance.state.loading).toBeUndefined();
935
+ listInstance.bulkDelete();
936
+ expectErrorToBeNull(listInstance.state.error);
937
+ expect(listInstance.state.errored).toBe(false);
938
+ expect(listInstance.state.loading).toBe(true);
939
+ await expect(() => listInstance.bulkDelete()).rejects.toThrow(ListInstanceError);
940
+ expectErrorToBeNull(listInstance.state.error);
941
+ expect(listInstance.state.errored).toBe(false);
942
+ expect(listInstance.state.loading).toBe(true);
943
+ });
944
+ it("errored", async function () {
945
+ const listArgs = reactive({
946
+ user: 1,
947
+ });
948
+ const retrieveArgs = reactive({
949
+ fields,
950
+ });
951
+ const listInstance = useListInstance({
952
+ props: { pkKey: "id", listArgs, retrieveArgs },
953
+ keepOldPages: false,
954
+ });
955
+ let crudListReject;
956
+ const crudListPromise = new Promise((resolve, reject) => {
957
+ crudListReject = reject;
958
+ });
959
+ let passedPageCallback;
960
+ globalbulkDelete.mockImplementation(({ pageCallback }) => {
961
+ passedPageCallback = pageCallback;
962
+ return crudListPromise;
963
+ });
964
+
965
+ expectErrorToBeNull(listInstance.state.error);
966
+ expect(listInstance.state.errored).toBe(false);
967
+ expect(listInstance.state.loading).toBeUndefined();
968
+ expect({ ...listInstance.state.objects }).toEqual({});
969
+
970
+ const liListResolve = listInstance.bulkDelete();
971
+
972
+ expectErrorToBeNull(listInstance.state.error);
973
+ expect(listInstance.state.errored).toBe(false);
974
+ expect(listInstance.state.loading).toBe(true);
975
+ expect({ ...listInstance.state.objects }).toEqual({});
976
+
977
+ await nextTick();
978
+
979
+ const rejected = new Error("Test Error");
980
+ // @ts-ignore - crudListReject is set in a promise, since we await this will be set
981
+ crudListReject(rejected);
982
+ await flushPromises();
983
+
984
+ await expect(liListResolve).resolves.toBe(false);
985
+
986
+ expect(listInstance.state.error).toBe(rejected);
987
+ expect(listInstance.state.errored).toBe(true);
988
+ expect(listInstance.state.loading).toBe(false);
989
+ expect({ ...listInstance.state.objects }).toEqual({});
990
+ expect(globalbulkDelete).toHaveBeenCalledWith({
991
+ crudArgs: { stream: "test_stream" },
992
+ pkKey: "id",
993
+ pks: [],
994
+ });
995
+ expect(globalbulkDelete).toHaveBeenCalledTimes(1);
996
+ });
685
997
  });
686
998
  describe("getFakePk", function () {
687
999
  it("returns fakeId", function () {
688
- const listInstance = useListInstance({ props: { pkKey: "id" } });
1000
+ const listInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
689
1001
  const fakeId = listInstance.getFakePk();
690
1002
  expect(fakeId).toBeTruthy();
691
1003
  });
@@ -716,6 +1028,7 @@ describe("use/listInstance.spec.js", function () {
716
1028
  };
717
1029
  const listInstance = useListInstance({
718
1030
  props: { pkKey: "id", listArgs: { user: 1 }, retrieveArgs: { fields: fields } },
1031
+ keepOldPages: false,
719
1032
  });
720
1033
  let crudListResolve;
721
1034
  const crudListPromise = new Promise((resolve) => {
@@ -771,6 +1084,7 @@ describe("use/listInstance.spec.js", function () {
771
1084
  functions: {
772
1085
  list: myListFn,
773
1086
  },
1087
+ keepOldPages: false,
774
1088
  });
775
1089
 
776
1090
  const cancelablePromise = listInstance.list();
@@ -793,4 +1107,29 @@ describe("use/listInstance.spec.js", function () {
793
1107
  expect(listInstance.state.loading).toBe(false);
794
1108
  });
795
1109
  });
1110
+ describe("useListInstance", function () {
1111
+ it("throw error when missing keepOldPages", async function () {
1112
+ const listArgs = reactive({
1113
+ user: 1,
1114
+ });
1115
+ const retrieveArgs = reactive({
1116
+ fields: fields,
1117
+ });
1118
+ expect(() =>
1119
+ useListInstance({
1120
+ props: { pkKey: "id", listArgs, retrieveArgs },
1121
+ keepOldPages: false,
1122
+ }).toThrow("useListInstance requires keepOldPages.")
1123
+ );
1124
+ });
1125
+ it("throw error when missing props", async function () {
1126
+ const listArgs = reactive({
1127
+ user: 1,
1128
+ });
1129
+ const retrieveArgs = reactive({
1130
+ fields: fields,
1131
+ });
1132
+ expect(() => useListInstance({}).toThrow("useListInstance requires props."));
1133
+ });
1134
+ });
796
1135
  });
@@ -13,8 +13,8 @@ describe("use/listRelated", () => {
13
13
  AwaitNot = watchesModule.AwaitNot;
14
14
  });
15
15
  it("should return a list of related items", async () => {
16
- const mainListInstance = useListInstance({ props: { pkKey: "id" } });
17
- const relatedListInstance = useListInstance({ props: { pkKey: "id" } });
16
+ const mainListInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
17
+ const relatedListInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
18
18
  mainListInstance.addListObject({
19
19
  id: "1",
20
20
  name: "main",
@@ -82,9 +82,9 @@ describe("use/listRelated", () => {
82
82
  });
83
83
  it('should allow related objects pkKey to be prefixed with "relatedItem." to reference previously related objects', async () => {
84
84
  //
85
- const mainListInstance = useListInstance({ props: { pkKey: "id" } });
86
- const intermediateListInstance = useListInstance({ props: { pkKey: "id" } });
87
- const relatedListInstance = useListInstance({ props: { pkKey: "id" } });
85
+ const mainListInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
86
+ const intermediateListInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
87
+ const relatedListInstance = useListInstance({ props: { pkKey: "id" }, keepOldPages: false });
88
88
  mainListInstance.addListObject({
89
89
  id: "1",
90
90
  name: "main",