fix(core): update

This commit is contained in:
2018-12-02 15:39:52 +01:00
parent 1edda548a1
commit 4df1274094
5 changed files with 262 additions and 56 deletions

View File

@ -1,38 +1,38 @@
import { expect, tap } from "@pushrocks/tapbundle";
import * as smartcache from "../ts/index";
import * as smartdelay from "@pushrocks/smartdelay";
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartcache from '../ts/index';
import * as smartdelay from '@pushrocks/smartdelay';
let smartcacheInstance: smartcache.SmartCache;
tap.test("should create a valid instance of SmartCache", async () => {
tap.test('should create a valid instance of SmartCache', async () => {
smartcacheInstance = new smartcache.SmartCache();
expect(smartcacheInstance).to.be.instanceof(smartcache.SmartCache);
});
tap.test("try to get async responses", async () => {
tap.test('try to get async responses', async () => {
const getResponse = async () => {
const response = await smartcacheInstance
.cacheReturn(async () => {
console.log("function ran");
return "hello";
console.log('function ran');
return 'hello';
}, 1000)
.catch(err => {
console.log(err);
});
console.log("response is:");
console.log('response is:');
console.log(response);
};
const getResponse2 = async () => {
const response = await smartcacheInstance
.cacheReturn(async () => {
console.log("function 2 ran");
return "hello";
console.log('function 2 ran');
return 'hello';
}, 1000)
.catch(err => {
console.log(err);
});
console.log("response is:");
console.log('response is:');
console.log(response);
};