@roc-db/test-utils 0.2.0-pre.92 → 0.2.0-pre.94
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/index.js +26 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -871,15 +871,23 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
871
871
|
expect2(() => adapter1.readPost(postRef)).toThrow(NotFoundError3);
|
|
872
872
|
});
|
|
873
873
|
test("sync mutation", async () => {
|
|
874
|
+
const {
|
|
875
|
+
persistedAt: ignore,
|
|
876
|
+
...createPostMutationWithoutPersistedAt
|
|
877
|
+
} = createPostMutation;
|
|
874
878
|
const [{ persistedAt, ...mutation }] = await adapter2.persistOptimisticMutations([createPostMutation]);
|
|
875
|
-
expect2(mutation).toStrictEqual(
|
|
879
|
+
expect2(mutation).toStrictEqual(createPostMutationWithoutPersistedAt);
|
|
876
880
|
});
|
|
877
881
|
test("sync mutation with debounce > 0", async () => {
|
|
878
882
|
const [post2, createPostMutation2] = await adapter1.createPost({
|
|
879
883
|
title: "Foo"
|
|
880
884
|
});
|
|
881
885
|
const [{ persistedAt, ...mutation }] = await adapter2.persistOptimisticMutations([createPostMutation2]);
|
|
882
|
-
|
|
886
|
+
const {
|
|
887
|
+
persistedAt: ignore,
|
|
888
|
+
...createPostMutationWithoutPersistedAt
|
|
889
|
+
} = createPostMutation2;
|
|
890
|
+
expect2(mutation).toStrictEqual(createPostMutationWithoutPersistedAt);
|
|
883
891
|
const res = await adapter1.updatePostTitle({
|
|
884
892
|
ref: post2.ref,
|
|
885
893
|
title: "A"
|
|
@@ -1111,6 +1119,21 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
1111
1119
|
expect2(allMutationsAdapter2after.length).toBe(allMutationsAdapter1.length);
|
|
1112
1120
|
const res2 = await adapterB.loadMutations(allMutationsAdapter1);
|
|
1113
1121
|
});
|
|
1122
|
+
test("persisted at", async () => {
|
|
1123
|
+
const adapterA = await createAdapter({ optimistic: false });
|
|
1124
|
+
const adapterB = await createAdapter({ optimistic: true });
|
|
1125
|
+
const [, mutationNonOptimistic] = await adapterA.createPost({
|
|
1126
|
+
title: "Foo"
|
|
1127
|
+
});
|
|
1128
|
+
expect2(mutationNonOptimistic.persistedAt).toBeDefined();
|
|
1129
|
+
expect2(mutationNonOptimistic.persistedAt).toBe(mutationNonOptimistic.timestamp);
|
|
1130
|
+
const [, mutationOptimistic] = await adapterB.createPost({
|
|
1131
|
+
title: "Foo"
|
|
1132
|
+
});
|
|
1133
|
+
expect2(mutationOptimistic.persistedAt).toBeNull();
|
|
1134
|
+
const [mutationOptimisticPersisted] = await adapterA.persistOptimisticMutations([mutationOptimistic]);
|
|
1135
|
+
expect2(mutationOptimisticPersisted.persistedAt).toBeString();
|
|
1136
|
+
});
|
|
1114
1137
|
test("persistOptimisticMutations", async () => {
|
|
1115
1138
|
const persistedAdapter = await createAdapter({ optimistic: false });
|
|
1116
1139
|
const optimisticAdapter = await createAdapter({ optimistic: true });
|
|
@@ -1127,7 +1150,7 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
1127
1150
|
expect2(persistCratePostMutation.persistedAt >= createPostMutation.timestamp).toBeTrue();
|
|
1128
1151
|
const readMutation2 = await persistedAdapter.readMutation(persistCratePostMutation.ref);
|
|
1129
1152
|
expect2(readMutation2).toStrictEqual(persistCratePostMutation);
|
|
1130
|
-
const [draft2, createDraftMutation] = await optimisticAdapter.createDraft({
|
|
1153
|
+
const [draft2, { persistedAt: ignore, ...createDraftMutation }] = await optimisticAdapter.createDraft({
|
|
1131
1154
|
postRef: post2.ref
|
|
1132
1155
|
});
|
|
1133
1156
|
const [{ persistedAt, ...persistedCreateDraftMutation }] = await persistedAdapter.persistOptimisticMutations([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roc-db/test-utils",
|
|
3
|
-
"version": "0.2.0-pre.
|
|
3
|
+
"version": "0.2.0-pre.94",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"roc-db": "0.2.0-pre.
|
|
20
|
+
"roc-db": "0.2.0-pre.94",
|
|
21
21
|
"zod": ">=4.0.0"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [],
|