taskbuffer/test/test.taskrunner.ts

35 lines
725 B
TypeScript
Raw Normal View History

import { tap, expect } from '@pushrocks/tapbundle';
2022-03-25 11:14:49 +00:00
import * as taskbuffer from '../ts/index.js';
let testTaskRunner: taskbuffer.TaskRunner;
tap.test('should create a valid taskrunner', async () => {
testTaskRunner = new taskbuffer.TaskRunner();
2019-11-28 14:42:28 +00:00
await testTaskRunner.start();
});
tap.test('should execute task when its scheduled', async (tools) => {
const done = tools.defer();
2020-07-12 00:48:51 +00:00
testTaskRunner.addTask(
new taskbuffer.Task({
taskFunction: async () => {
console.log('hi');
},
})
);
2020-07-12 00:48:51 +00:00
testTaskRunner.addTask(
new taskbuffer.Task({
taskFunction: async () => {
console.log('there');
done.resolve();
},
})
);
await done.promise;
});
2020-07-12 00:48:51 +00:00
tap.start();