webstore/test/test.browser.ts

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-07-09 22:30:33 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
import * as webstore from '../ts/index';
2020-07-09 23:03:01 +00:00
let testWebstore: webstore.WebStore;
2020-07-09 22:30:33 +00:00
tap.test('first test', async () => {
2020-07-09 23:03:01 +00:00
testWebstore = new webstore.WebStore({
2020-07-11 17:15:24 +00:00
dbName: 'mytest-db',
storeName: 'mytest-store'
2020-07-09 23:03:01 +00:00
});
2020-07-09 22:30:33 +00:00
expect(testWebstore).to.be.instanceOf(webstore.WebStore);
});
2020-07-09 23:03:01 +00:00
tap.test('should init the database', async () => {
await testWebstore.init();
});
tap.test('should store a value', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal'
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
2020-07-11 17:15:24 +00:00
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).to.be.false;
expect(resultThere).to.be.true;
});
2020-07-09 22:30:33 +00:00
tap.start();