fix(package): project setup

This commit is contained in:
2018-07-12 23:52:06 +02:00
parent c2740ca25b
commit 073d792497
7 changed files with 705 additions and 46 deletions

View File

@ -1,36 +1,51 @@
// import { expect, tap } from 'tapbundle';
import * as smartcache from '../ts/index';
import * as smartdelay from '@pushrocks/smartdelay';
import { expect, tap } from "tapbundle";
import * as smartcache from "../ts/index";
import * as smartdelay from "@pushrocks/smartdelay";
const smartcacheInstance = new smartcache.SmartCache();
const getResponse = async () => {
const response = await smartcacheInstance.cacheReturn(async () => {
console.log('function ran')
return 'hello';
}, 1000).catch(err => {
console.log(err);
});
console.log('response is:')
console.log(response);
};
let smartcacheInstance: smartcache.SmartCache;
const getResponse2 = async () => {
const response = await smartcacheInstance.cacheReturn(async () => {
console.log('function ran')
return 'hello';
}, 1000).catch(err => {
console.log(err);
});
console.log('response is:')
console.log(response);
};
getResponse();
getResponse();
getResponse2();
getResponse2();
smartdelay.delayFor(1000).then(() => {
getResponse();
// getResponse2();
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 () => {
const getResponse = async () => {
const response = await smartcacheInstance
.cacheReturn(async () => {
console.log("function ran");
return "hello";
}, 1000)
.catch(err => {
console.log(err);
});
console.log("response is:");
console.log(response);
};
const getResponse2 = async () => {
const response = await smartcacheInstance
.cacheReturn(async () => {
console.log("function 2 ran");
return "hello";
}, 1000)
.catch(err => {
console.log(err);
});
console.log("response is:");
console.log(response);
};
getResponse();
getResponse();
getResponse2();
getResponse2();
smartdelay.delayFor(1000).then(() => {
getResponse();
// getResponse2();
});
});
tap.start({
throwOnError: true
});