2019-09-22 13:16:27 +00:00
|
|
|
import { tap, expect } from '@pushrocks/tapbundle';
|
|
|
|
|
2019-11-28 11:33:26 +00:00
|
|
|
import * as taskbuffer from '../ts';
|
2019-09-22 13:16:27 +00:00
|
|
|
|
|
|
|
let preTask: taskbuffer.Task;
|
|
|
|
let afterTask: taskbuffer.Task;
|
|
|
|
|
|
|
|
let mainTask: taskbuffer.Task;
|
|
|
|
|
|
|
|
tap.test('should create tasks', async () => {
|
|
|
|
preTask = new taskbuffer.Task({
|
|
|
|
name: 'myPreTask',
|
|
|
|
taskFunction: async () => {
|
|
|
|
console.log('pretask executed :)');
|
2019-09-23 14:31:06 +00:00
|
|
|
return 'hi';
|
2020-07-12 00:48:51 +00:00
|
|
|
},
|
2019-09-22 13:16:27 +00:00
|
|
|
});
|
|
|
|
afterTask = new taskbuffer.Task({
|
|
|
|
name: 'myAfterTask',
|
2020-07-12 00:48:51 +00:00
|
|
|
taskFunction: async (x) => {
|
2019-09-23 14:31:06 +00:00
|
|
|
if (x === 'hi') {
|
|
|
|
console.log('afterTask: values get passed along alright');
|
|
|
|
}
|
2019-09-22 13:16:27 +00:00
|
|
|
console.log('afterTask executed :)');
|
2019-09-23 14:31:06 +00:00
|
|
|
return x;
|
2019-09-22 13:16:27 +00:00
|
|
|
},
|
|
|
|
preTask,
|
2020-07-12 00:48:51 +00:00
|
|
|
afterTask,
|
2019-09-22 13:16:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
mainTask = new taskbuffer.Task({
|
|
|
|
name: 'mainTask',
|
2020-07-12 00:48:51 +00:00
|
|
|
taskFunction: async (x) => {
|
2019-09-23 14:31:06 +00:00
|
|
|
if (x === 'hi') {
|
|
|
|
console.log('mainTask: values get passed along alright');
|
|
|
|
}
|
|
|
|
console.log('afterTask executed :)');
|
|
|
|
return x;
|
2019-09-22 13:16:27 +00:00
|
|
|
},
|
2019-09-23 16:06:43 +00:00
|
|
|
preTask: () => {
|
|
|
|
return preTask;
|
|
|
|
},
|
2020-07-12 00:48:51 +00:00
|
|
|
afterTask,
|
2019-09-22 13:16:27 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-09-23 16:06:43 +00:00
|
|
|
tap.test('should execute the mainTask', async () => {
|
2019-09-22 13:16:27 +00:00
|
|
|
await mainTask.trigger();
|
|
|
|
});
|
|
|
|
|
2019-11-28 11:33:26 +00:00
|
|
|
tap.start();
|