@x5e/gink
Version:
an eventually consistent database
34 lines • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Store_test_1 = require("./Store.test");
const implementation_1 = require("../implementation");
(0, Store_test_1.testStore)("MemoryStore", async () => new implementation_1.MemoryStore(true));
it("test basic operations", async () => {
const memStore = new implementation_1.MemoryStore(true);
const instance = new implementation_1.Database(memStore);
await instance.ready;
const dir = instance.getGlobalDirectory();
await dir.set("foo", "bar");
const beforeSecondSet = (0, implementation_1.generateTimestamp)();
await dir.set("foo", "baz");
const entries = memStore.getAllEntries();
(0, implementation_1.ensure)(entries.length === 2);
const removals = memStore.getAllRemovals();
(0, implementation_1.ensure)(removals.size === 1, `removals.size is ${removals.size}, expected 1`);
/*
await memStore.dropHistory();
const entriesAfterDrop = memStore.getAllEntryKeys();
ensure(Array.from(entriesAfterDrop).length === 1);
ensure(!await dir.has("foo", beforeSecondSet));
*/
});
it("tests getEntryByKey and getKeyedEntries", async () => {
const memStore = new implementation_1.MemoryStore(true);
const instance = new implementation_1.Database(memStore);
await instance.ready;
const dir = instance.getGlobalDirectory();
const id = await dir.set("foo", "bar");
await dir.set("bar", "foo");
(0, implementation_1.ensure)((await memStore.getKeyedEntries(dir.address)).size === 2);
});
//# sourceMappingURL=MemoryStore.test.js.map