webstore/test/skip.coexistence.smartntml.ts

45 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2023-07-27 11:51:40 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
2023-05-01 10:44:59 +00:00
2023-07-27 11:51:40 +00:00
import * as smartntml from '@push.rocks/smartntml';
2023-05-01 10:44:59 +00:00
const smartntmlInstance = new smartntml.Smartntml();
import * as webstore from '../ts/index.js';
let testWebstore: webstore.WebStore;
tap.test('first test', async () => {
testWebstore = new webstore.WebStore({
dbName: 'mytest-db',
storeName: 'mytest-store',
});
expect(testWebstore).toBeInstanceOf(webstore.WebStore);
});
tap.test('should allow storing a string', async () => {
await testWebstore.set('mystring', 'heythere');
expect(await testWebstore.get('mystring')).toEqual('heythere');
});
tap.test('should allow storing an object', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal',
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.test('should overwrite a value', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal2',
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.test('should correctly check the existence of keys', async () => {
const resultNotThere = await testWebstore.check('notThere');
const resultThere = await testWebstore.check('testProp1');
expect(resultNotThere).toBeFalse();
expect(resultThere).toBeTrue();
});
tap.start();