2018-08-04 15:53:22 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import taskbuffer = require('../ts/index');
|
2017-06-17 14:56:33 +00:00
|
|
|
|
2018-08-04 15:53:22 +00:00
|
|
|
import * as smartq from 'smartq';
|
|
|
|
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;
|
2017-06-17 14:56:33 +00:00
|
|
|
let task1 = new taskbuffer.Task({
|
|
|
|
taskFunction: async () => {
|
2018-08-04 15:53:22 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
task1Executed = true;
|
2017-06-17 14:56:33 +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;
|
2017-06-17 14:56:33 +00:00
|
|
|
let task2 = new taskbuffer.Task({
|
|
|
|
taskFunction: async () => {
|
2018-08-04 15:53:22 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
task2Executed = true;
|
2017-06-17 14:56:33 +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;
|
2017-06-17 14:56:33 +00:00
|
|
|
let task3 = new taskbuffer.Task({
|
|
|
|
taskFunction: async () => {
|
2018-08-04 15:53:22 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
task3Executed = true;
|
2017-06-17 14:56:33 +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 () => {
|
|
|
|
let testTaskparallel = new taskbuffer.Taskparallel({
|
2018-08-04 15:53:22 +00:00
|
|
|
taskArray: [task1, task2, task3]
|
|
|
|
});
|
|
|
|
await testTaskparallel.trigger();
|
|
|
|
});
|
2017-06-17 14:56:33 +00:00
|
|
|
|
2018-08-04 15:53:22 +00:00
|
|
|
tap.start();
|