2023-07-26 12:16:33 +00:00
|
|
|
import { tap, expect } from '@push.rocks/tapbundle';
|
2022-03-25 11:14:49 +00:00
|
|
|
|
|
|
|
import * as taskbuffer from '../ts/index.js';
|
2019-11-28 11:33:26 +00:00
|
|
|
|
|
|
|
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();
|
2019-11-28 11:33:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
2019-11-28 11:33:26 +00:00
|
|
|
|
2020-07-12 00:48:51 +00:00
|
|
|
testTaskRunner.addTask(
|
|
|
|
new taskbuffer.Task({
|
|
|
|
taskFunction: async () => {
|
|
|
|
console.log('there');
|
|
|
|
done.resolve();
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
2019-11-28 11:33:26 +00:00
|
|
|
|
|
|
|
await done.promise;
|
|
|
|
});
|
|
|
|
|
2020-07-12 00:48:51 +00:00
|
|
|
tap.start();
|