2018-08-04 15:53:22 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import taskbuffer = require('../ts/index');
|
|
|
|
import * as smartdelay from '@pushrocks/smartdelay';
|
2017-06-17 14:56:33 +00:00
|
|
|
|
2018-08-04 15:53:22 +00:00
|
|
|
let task1Executed = false;
|
2019-09-05 09:35:26 +00:00
|
|
|
const task1 = new taskbuffer.Task({
|
2017-06-17 14:56:33 +00:00
|
|
|
taskFunction: async () => {
|
2018-08-04 15:53:22 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
task1Executed = true;
|
2020-07-12 00:48:51 +00:00
|
|
|
},
|
2018-08-04 15:53:22 +00:00
|
|
|
});
|
2017-06-17 14:56:33 +00:00
|
|
|
|
2018-08-04 15:53:22 +00:00
|
|
|
let task2Executed = false;
|
2019-09-05 09:35:26 +00:00
|
|
|
const task2 = new taskbuffer.Task({
|
2017-06-17 14:56:33 +00:00
|
|
|
taskFunction: async () => {
|
2018-08-04 15:53:22 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
task2Executed = true;
|
2020-07-12 00:48:51 +00:00
|
|
|
},
|
2018-08-04 15:53:22 +00:00
|
|
|
});
|
2017-06-17 14:56:33 +00:00
|
|
|
|
2018-08-04 15:53:22 +00:00
|
|
|
let task3Executed = false;
|
2019-09-05 09:35:26 +00:00
|
|
|
const task3 = new taskbuffer.Task({
|
2017-06-17 14:56:33 +00:00
|
|
|
taskFunction: async () => {
|
2018-08-04 15:53:22 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
task3Executed = true;
|
2020-07-12 00:48:51 +00:00
|
|
|
},
|
2018-08-04 15:53:22 +00:00
|
|
|
});
|
2017-06-17 14:56:33 +00:00
|
|
|
|
|
|
|
tap.test('expect run in Parallel', async () => {
|
2019-09-05 09:35:26 +00:00
|
|
|
const testTaskparallel = new taskbuffer.Taskparallel({
|
2020-07-12 00:48:51 +00:00
|
|
|
taskArray: [task1, task2, task3],
|
2018-08-04 15:53:22 +00:00
|
|
|
});
|
|
|
|
await testTaskparallel.trigger();
|
|
|
|
});
|
2017-06-17 14:56:33 +00:00
|
|
|
|
2018-08-04 15:53:22 +00:00
|
|
|
tap.start();
|