29 lines
678 B
TypeScript
29 lines
678 B
TypeScript
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import * as taskbuffer from '../ts/index';
|
|
|
|
let myNumber = 0;
|
|
let myTaskOnce: taskbuffer.TaskOnce;
|
|
|
|
tap.test('should create a valid instance of TaskOnce', async () => {
|
|
myTaskOnce = new taskbuffer.TaskOnce({
|
|
taskFunction: async () => {
|
|
myNumber++;
|
|
},
|
|
});
|
|
expect(myTaskOnce).to.be.instanceof(taskbuffer.TaskOnce);
|
|
});
|
|
|
|
tap.test('myNumber should still be 0', async () => {
|
|
expect(myNumber).to.equal(0);
|
|
});
|
|
|
|
tap.test('myTaskOnce should trigger once', async () => {
|
|
await myTaskOnce.trigger();
|
|
await myTaskOnce.trigger();
|
|
await myTaskOnce.trigger();
|
|
expect(myNumber).to.equal(1);
|
|
});
|
|
|
|
tap.start();
|