Skip to content

Commit

Permalink
Updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
dfahlander committed Jul 28, 2024
1 parent 4ceb588 commit 54ef0e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions test/tests-yjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
promisedTest,
} from './dexie-unittest-utils';
import * as Y from 'yjs';
import * as awareness from 'y-protocols/awareness';

const db = new Dexie('TestYjs', { Y });
db.version(1).stores({
Expand Down Expand Up @@ -95,7 +96,7 @@ promisedTest('Test Y document compression', async () => {
// Verify there are no updates in the updates table initially:
const updateTable = db.docs.schema.yProps.find(
(p) => p.prop === 'content'
).updTable;
).updatesTable;
equal(await db.table(updateTable).count(), 0, 'No docs stored yet');

// Create three updates:
Expand Down Expand Up @@ -168,14 +169,16 @@ promisedTest('Test that syncers prohibit GC from compressing unsynced updates',
// Verify there are no updates in the updates table initially:
const updateTable = db.docs.schema.yProps.find(
(p) => p.prop === 'content'
).updTable;
).updatesTable;
equal(await db.table(updateTable).where('i').between(1,Infinity).count(), 0, 'No docs stored yet');

// Create three updates:
await db.transaction('rw', db.docs, () => {
//Y.transact(doc, () => {
doc.getArray('arr').insert(0, ['a', 'b', 'c']);
doc.getArray('arr').insert(0, ['1', '2', '3']);
doc.getArray('arr').insert(0, ['x', 'y', 'z']);
//});
});
// Verify we have 3 updates:
equal(await db.table(updateTable).where('i').between(1,Infinity).count(), 3, 'Three updates stored');
Expand All @@ -195,4 +198,14 @@ promisedTest('Test that syncers prohibit GC from compressing unsynced updates',
// Verify we have 0 updates after deleting the row holding our Y.Doc property:
equal(await db.table(updateTable).where('i').between(1, Infinity).count(), 0, '0 updates stored');
ok(provider.destroyed, "Provider was destroyed when our document was deleted");
});
});


/*promisedTest('Test awareness', async () => {
const doc = new Y.Doc();
const aw = new awareness.Awareness(doc);
console.log(Array.from(aw.getStates().keys()));
const update = awareness.encodeAwarenessUpdate(aw, Array.from(aw.getStates().keys()));
console.log("Update length", update.length);
});
*/
2 changes: 1 addition & 1 deletion test/typings-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"noImplicitThis": true,
"outDir": "../../tools/tmp/test-typings",
"moduleResolution": "node",
"lib": ["dom", "es2020"]
"lib": ["dom", "es2021"]
},
"files": [
"test-typings.ts"
Expand Down

0 comments on commit 54ef0e7

Please sign in to comment.