BREAKING CHANGE(core): switch to esm

This commit is contained in:
2022-03-22 22:45:12 +01:00
parent 9feaa921bf
commit 716d805723
18 changed files with 16306 additions and 8513 deletions

View File

@ -1,6 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as levelcache from '../ts/index';
import { CacheEntry } from '../ts/index';
import * as levelcache from '../ts/index.js';
import { CacheEntry } from '../ts/index.js';
let testLevelCache: levelcache.LevelCache;
@ -8,7 +8,7 @@ tap.test('should create a new levelcache instance', async () => {
testLevelCache = new levelcache.LevelCache({
cacheId: 'myCache',
});
expect(testLevelCache).to.be.instanceOf(levelcache.LevelCache);
expect(testLevelCache).toBeInstanceOf(levelcache.LevelCache);
});
tap.test('should cache a value', async () => {
@ -21,7 +21,7 @@ tap.test('should cache a value', async () => {
})
);
const result = await testLevelCache.retrieveCacheEntryByKey('mykey');
expect(result.contents.toString()).to.equal('heythere');
expect(result.contents.toString()).toEqual('heythere');
});
tap.test('should respect ttl', async (tools) => {
@ -34,10 +34,10 @@ tap.test('should respect ttl', async (tools) => {
})
);
const result = await testLevelCache.retrieveCacheEntryByKey('mykey');
expect(result.contents.toString()).to.equal('heythere');
expect(result.contents.toString()).toEqual('heythere');
await tools.delayFor(1100);
const result2 = await testLevelCache.retrieveCacheEntryByKey('mykey');
expect(result2).to.be.null;
expect(result2).toBeNull();
});
tap.start();