feat(taskrunner): now has working taskrunner

This commit is contained in:
2019-11-28 11:33:26 +00:00
parent af5fa857cc
commit 138aefc499
11 changed files with 137 additions and 81 deletions

View File

@ -1,6 +1,6 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as taskbuffer from '../ts';
import * as taskbuffer from '../ts';
let preTask: taskbuffer.Task;
let afterTask: taskbuffer.Task;
@ -17,7 +17,7 @@ tap.test('should create tasks', async () => {
});
afterTask = new taskbuffer.Task({
name: 'myAfterTask',
taskFunction: async (x) => {
taskFunction: async x => {
if (x === 'hi') {
console.log('afterTask: values get passed along alright');
}
@ -30,7 +30,7 @@ tap.test('should create tasks', async () => {
mainTask = new taskbuffer.Task({
name: 'mainTask',
taskFunction: async (x) => {
taskFunction: async x => {
if (x === 'hi') {
console.log('mainTask: values get passed along alright');
}
@ -48,4 +48,4 @@ tap.test('should execute the mainTask', async () => {
await mainTask.trigger();
});
tap.start();
tap.start();

29
test/test.taskrunner.ts Normal file
View File

@ -0,0 +1,29 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as taskbuffer from '../ts/index';
let testTaskRunner: taskbuffer.TaskRunner;
tap.test('should create a valid taskrunner', async () => {
testTaskRunner = new taskbuffer.TaskRunner();
testTaskRunner.start();
});
tap.test('should execute task when its scheduled', async (tools) => {
const done = tools.defer();
testTaskRunner.addTask(new taskbuffer.Task({
taskFunction: async () => {
console.log('hi');
}
}));
testTaskRunner.addTask(new taskbuffer.Task({
taskFunction: async () => {
console.log('there');
done.resolve();
}
}));
await done.promise;
});
tap.start();