Files
smartconfig/test/test.kvstore.ts
Juergen Kunz 22a9aa9f3e rename package from @push.rocks/npmextra to @push.rocks/smartconfig
- Rename all source files from npmextra.* to simpler names (classes.appdata.ts, etc.)
- Rename Npmextra class to Smartconfig
- Config file changed from npmextra.json to smartconfig.json
- KV store path changed from ~/.npmextra/kv to ~/.smartconfig/kv
- Update all imports, tests, and metadata
2026-03-24 14:56:23 +00:00

33 lines
923 B
TypeScript

import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartconfig from '../ts/index.js';
let myKeyValueStore: smartconfig.KeyValueStore<any>;
tap.test('should create a keyValueStore', async () => {
myKeyValueStore = new smartconfig.KeyValueStore<any>({
typeArg: 'custom',
identityArg: 'test',
customPath: 'test/somekv.json',
});
expect(myKeyValueStore).toBeInstanceOf(smartconfig.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');
});
export default tap.start();