lik/test/test.looptracker.ts

27 lines
810 B
TypeScript
Raw Permalink Normal View History

2017-07-05 12:29:08 +00:00
// import test framework
2018-07-15 14:04:27 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
import * as events from 'events';
2018-08-31 15:24:35 +00:00
import * as smartpromise from '@pushrocks/smartpromise';
2017-07-05 12:29:08 +00:00
// import the module
2018-07-15 14:04:27 +00:00
import * as lik from '../ts/index';
2017-07-05 12:29:08 +00:00
2018-07-15 14:04:27 +00:00
let object1 = {};
let object2 = {};
let myLoopTracker: lik.LoopTracker<any>;
2017-07-05 12:29:08 +00:00
// tests
tap.test('should create a valid looptracker instance', async () => {
2018-07-15 14:04:27 +00:00
myLoopTracker = new lik.LoopTracker();
expect(myLoopTracker).to.be.instanceof(lik.LoopTracker);
});
2017-07-05 12:37:26 +00:00
tap.test('should add objects once and return true', async () => {
2018-07-15 14:04:27 +00:00
expect(myLoopTracker.checkAndTrack(object1)).to.be.true;
expect(myLoopTracker.checkAndTrack(object1)).to.be.false;
expect(myLoopTracker.checkAndTrack(object2)).to.be.true;
expect(myLoopTracker.checkAndTrack(object2)).to.be.false;
});
2017-07-05 12:37:26 +00:00
2018-07-15 14:04:27 +00:00
tap.start();