fix(core): update
This commit is contained in:
21
test/test.ts
21
test/test.ts
@ -1,6 +1,5 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartcache from '../ts/index';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
|
||||
let smartcacheInstance: smartcache.SmartCache;
|
||||
|
||||
@ -9,27 +8,31 @@ tap.test('should create a valid instance of SmartCache', async () => {
|
||||
expect(smartcacheInstance).to.be.instanceof(smartcache.SmartCache);
|
||||
});
|
||||
|
||||
tap.test('try to get async responses', async () => {
|
||||
tap.test('try to get async responses', async (tools) => {
|
||||
let response1Counter = 0;
|
||||
const getResponse = async () => {
|
||||
const response = await smartcacheInstance
|
||||
.cacheReturn(async () => {
|
||||
console.log('function 1 ran');
|
||||
response1Counter++;
|
||||
return 'hello';
|
||||
}, 1000)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log('response is:');
|
||||
console.log(response);
|
||||
};
|
||||
|
||||
let response2Counter = 0;
|
||||
const getResponse2 = async () => {
|
||||
const response = await smartcacheInstance
|
||||
.cacheReturn(async () => {
|
||||
console.log('function 2 ran');
|
||||
response2Counter++;
|
||||
return 'hello there!';
|
||||
}, 1000)
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log('response is:');
|
||||
@ -40,12 +43,12 @@ tap.test('try to get async responses', async () => {
|
||||
await getResponse();
|
||||
await getResponse2();
|
||||
await getResponse2();
|
||||
await smartdelay.delayFor(2000).then(async () => {
|
||||
await getResponse();
|
||||
await getResponse2();
|
||||
});
|
||||
await tools.delayFor(500);
|
||||
await getResponse();
|
||||
await tools.delayFor(2000);
|
||||
await getResponse2();
|
||||
});
|
||||
|
||||
tap.start({
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
|
Reference in New Issue
Block a user