29 lines
828 B
TypeScript
29 lines
828 B
TypeScript
import { expect, tap } from '@push.rocks/tapbundle';
|
|
|
|
import * as npmextra from '../ts/index.js';
|
|
|
|
let myKeyValueStore: npmextra.KeyValueStore;
|
|
|
|
tap.test('should create a keyValueStore', async () => {
|
|
myKeyValueStore = new npmextra.KeyValueStore('custom', 'test', 'test/somekv.json');
|
|
expect(myKeyValueStore).toBeInstanceOf(npmextra.KeyValueStore);
|
|
});
|
|
|
|
tap.test('should reset the keyValueStore', async () => {
|
|
await myKeyValueStore.reset();
|
|
});
|
|
|
|
tap.test('expect result to be empty', async () => {
|
|
let result = await myKeyValueStore.readAll();
|
|
expect(JSON.stringify(result)).toEqual('{}');
|
|
});
|
|
|
|
tap.test('expect to add an object to the kv Store', async () => {
|
|
await myKeyValueStore.writeAll({
|
|
myKey: 'myValue',
|
|
});
|
|
await expect(await myKeyValueStore.readKey('myKey')).toEqual('myValue');
|
|
});
|
|
|
|
tap.start();
|