@fireproof/core 0.20.0-dev-preview-40 → 0.20.0-dev-preview-41
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/README.md +6 -4
- package/deno/index.js +2 -2
- package/deno/index.js.map +1 -1
- package/index.cjs +499 -370
- package/index.cjs.map +1 -1
- package/index.d.cts +162 -64
- package/index.d.ts +162 -64
- package/index.js +473 -344
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +3 -3
- package/react/index.cjs +17 -9
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +2 -1
- package/react/index.d.ts +2 -1
- package/react/index.js +17 -9
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/interceptor-gateway.test.ts +5 -1
- package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +8 -18
- package/tests/blockstore/keyed-crypto.test.ts +7 -30
- package/tests/blockstore/loader.test.ts +19 -17
- package/tests/blockstore/store.test.ts +48 -51
- package/tests/blockstore/transaction.test.ts +13 -11
- package/tests/fireproof/all-gateway.test.ts +49 -46
- package/tests/fireproof/attachable.test.ts +82 -0
- package/tests/fireproof/crdt.test.ts +49 -48
- package/tests/fireproof/database.test.ts +40 -40
- package/tests/fireproof/fireproof.test.ts +43 -42
- package/tests/fireproof/hello.test.ts +4 -4
- package/tests/fireproof/indexer.test.ts +44 -44
- package/tests/fireproof/utils.test.ts +4 -3
- package/tests/gateway/file/loader-config.test.ts +17 -17
- package/tests/gateway/indexeddb/loader-config.test.ts +4 -4
- package/tests/helpers.ts +80 -2
- package/tests/react/useFireproof.test.tsx +40 -4
@@ -20,7 +20,7 @@ describe("HOOK: useFireproof", () => {
|
|
20
20
|
});
|
21
21
|
|
22
22
|
describe("HOOK: useFireproof useLiveQuery has results", () => {
|
23
|
-
const dbName = "
|
23
|
+
const dbName = "useLiveQueryHasResults";
|
24
24
|
let db: Database,
|
25
25
|
query: LiveQueryResult<{ foo: string }, string>,
|
26
26
|
database: ReturnType<typeof useFireproof>["database"],
|
@@ -269,9 +269,8 @@ describe("HOOK: useFireproof useDocument has results reset sync", () => {
|
|
269
269
|
|
270
270
|
const allDocs = await db.allDocs<{ input: string }>();
|
271
271
|
expect(allDocs.rows.length).toBe(3);
|
272
|
-
|
273
|
-
expect(
|
274
|
-
expect(allDocs.rows[2].value.input).toBe("fresh");
|
272
|
+
const inputs = allDocs.rows.map((r) => r.value.input);
|
273
|
+
expect(inputs).toEqual(expect.arrayContaining(["first", "new", "fresh"]));
|
275
274
|
});
|
276
275
|
|
277
276
|
afterEach(async () => {
|
@@ -511,3 +510,40 @@ describe("HOOK: useFireproof race condition: calling save() without await overwr
|
|
511
510
|
await db.destroy();
|
512
511
|
});
|
513
512
|
});
|
513
|
+
|
514
|
+
describe("useFireproo calling submit()", () => {
|
515
|
+
const dbName = "submitDb";
|
516
|
+
let db: Database, docResult: UseDocumentResult<{ input: string }>;
|
517
|
+
|
518
|
+
beforeEach(async () => {
|
519
|
+
db = fireproof(dbName);
|
520
|
+
|
521
|
+
// Render a new hook instance
|
522
|
+
renderHook(() => {
|
523
|
+
const { useDocument } = useFireproof(dbName);
|
524
|
+
docResult = useDocument<{ input: string }>({ input: "" });
|
525
|
+
});
|
526
|
+
});
|
527
|
+
|
528
|
+
it("demonstrates that calling docResult.save() and docResult.reset() in the same tick can overwrite reset", async () => {
|
529
|
+
// Merge some changes into doc
|
530
|
+
docResult.merge({ input: "some data" });
|
531
|
+
|
532
|
+
docResult.submit();
|
533
|
+
|
534
|
+
// Let the async subscription produce a new doc in case the doc is reloaded with an _id
|
535
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
536
|
+
|
537
|
+
// If the reset worked, doc._id should STILL be undefined.
|
538
|
+
// If the subscription wins, doc._id will be defined => test fails.
|
539
|
+
await waitFor(() => {
|
540
|
+
expect(docResult.doc._id).toBeUndefined();
|
541
|
+
expect(docResult.doc.input).toBe("");
|
542
|
+
});
|
543
|
+
});
|
544
|
+
|
545
|
+
afterEach(async () => {
|
546
|
+
await db.close();
|
547
|
+
await db.destroy();
|
548
|
+
});
|
549
|
+
});
|