lik/test/test.looptracker.both.ts
2023-11-09 21:17:13 +01:00

25 lines
726 B
TypeScript

// import test framework
import { expect, tap } from '@pushrocks/tapbundle';
// import the module
import * as lik from '../ts/index.js';
let object1 = {};
let object2 = {};
let myLoopTracker: lik.LoopTracker<any>;
// tests
tap.test('should create a valid looptracker instance', async () => {
myLoopTracker = new lik.LoopTracker();
expect(myLoopTracker).toBeInstanceOf(lik.LoopTracker);
});
tap.test('should add objects once and return true', async () => {
expect(myLoopTracker.checkAndTrack(object1)).toBeTrue();
expect(myLoopTracker.checkAndTrack(object1)).toBeFalse();
expect(myLoopTracker.checkAndTrack(object2)).toBeTrue();
expect(myLoopTracker.checkAndTrack(object2)).toBeFalse();
});
await tap.start();