diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-06-21 19:18:36 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-06-21 19:18:36 +0200 |
commit | a4e4125cca8644703d7cff527a39c1a5a9842eba (patch) | |
tree | fb4de931ea0db1f314fcf6850806989a40c9e76e /packages/idb-bridge/src/util/makeStoreKeyValue.test.ts | |
parent | 2ee9431f1ba5bf67546bbf85758a01991c40673f (diff) | |
download | wallet-core-a4e4125cca8644703d7cff527a39c1a5a9842eba.tar.xz |
idb: tests working
Diffstat (limited to 'packages/idb-bridge/src/util/makeStoreKeyValue.test.ts')
-rw-r--r-- | packages/idb-bridge/src/util/makeStoreKeyValue.test.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts b/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts new file mode 100644 index 000000000..7820875c3 --- /dev/null +++ b/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts @@ -0,0 +1,42 @@ +import test from 'ava'; +import { makeStoreKeyValue } from "./makeStoreKeyValue"; + +test("basics", (t) => { + let result; + + result = makeStoreKeyValue({ name: "Florian" }, undefined, 42, true, "id"); + t.is(result.updatedKeyGenerator, 43); + t.is(result.key, 42); + t.is(result.value.name, "Florian"); + t.is(result.value.id, 42); + + result = makeStoreKeyValue({ name: "Florian", id: 10 }, undefined, 5, true, "id"); + t.is(result.updatedKeyGenerator, 11); + t.is(result.key, 10); + t.is(result.value.name, "Florian"); + t.is(result.value.id, 10); + + result = makeStoreKeyValue({ name: "Florian", id: 5 }, undefined, 10, true, "id"); + t.is(result.updatedKeyGenerator, 10); + t.is(result.key, 5); + t.is(result.value.name, "Florian"); + t.is(result.value.id, 5); + + result = makeStoreKeyValue({ name: "Florian", id: "foo" }, undefined, 10, true, "id"); + t.is(result.updatedKeyGenerator, 10); + t.is(result.key, "foo"); + t.is(result.value.name, "Florian"); + t.is(result.value.id, "foo"); + + result = makeStoreKeyValue({ name: "Florian" }, "foo", 10, true, null); + t.is(result.updatedKeyGenerator, 10); + t.is(result.key, "foo"); + t.is(result.value.name, "Florian"); + t.is(result.value.id, undefined); + + result = makeStoreKeyValue({ name: "Florian" }, undefined, 10, true, null); + t.is(result.updatedKeyGenerator, 11); + t.is(result.key, 10); + t.is(result.value.name, "Florian"); + t.is(result.value.id, undefined); +}); |