npmextra/test/test.kvstore.ts

25 lines
713 B
TypeScript
Raw Normal View History

2023-08-03 17:22:34 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
2017-07-12 15:13:29 +00:00
2023-08-03 17:22:34 +00:00
import * as npmextra from '../ts/index.js';
2017-07-12 15:13:29 +00:00
let myKeyValueStore: npmextra.KeyValueStore;
2017-07-12 15:13:29 +00:00
tap.test('should create a keyValueStore', async () => {
myKeyValueStore = new npmextra.KeyValueStore('custom', 'test');
2023-08-03 17:22:34 +00:00
expect(myKeyValueStore).toBeInstanceOf(npmextra.KeyValueStore);
});
2017-07-12 15:13:29 +00:00
tap.test('expect result to be empty', async () => {
2023-08-03 17:22:34 +00:00
let result = await myKeyValueStore.readAll();
expect(JSON.stringify(result)).toEqual('{}');
});
2017-07-12 15:13:29 +00:00
tap.test('expect to add an object to the kv Store', async () => {
2017-08-16 16:25:45 +00:00
await myKeyValueStore.writeAll({
2021-01-27 21:00:49 +00:00
myKey: 'myValue',
});
2023-08-03 17:22:34 +00:00
await expect(await myKeyValueStore.readKey('myKey')).toEqual('myValue');
});
2017-07-12 15:13:29 +00:00
tap.start();