fix(core): update
This commit is contained in:
parent
3f749dfdd2
commit
df21ebd581
@ -5,7 +5,7 @@ import * as smartpromise from '@pushrocks/smartpromise';
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
|
||||||
let task1Executed = false;
|
let task1Executed = false;
|
||||||
let task1 = new taskbuffer.Task({
|
const task1 = new taskbuffer.Task({
|
||||||
taskFunction: async () => {
|
taskFunction: async () => {
|
||||||
await smartdelay.delayFor(2000);
|
await smartdelay.delayFor(2000);
|
||||||
task1Executed = true;
|
task1Executed = true;
|
||||||
@ -13,7 +13,7 @@ let task1 = new taskbuffer.Task({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let task2Executed = false;
|
let task2Executed = false;
|
||||||
let task2 = new taskbuffer.Task({
|
const task2 = new taskbuffer.Task({
|
||||||
taskFunction: async () => {
|
taskFunction: async () => {
|
||||||
await smartdelay.delayFor(2000);
|
await smartdelay.delayFor(2000);
|
||||||
task2Executed = true;
|
task2Executed = true;
|
||||||
@ -21,7 +21,7 @@ let task2 = new taskbuffer.Task({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let task3Executed = false;
|
let task3Executed = false;
|
||||||
let task3 = new taskbuffer.Task({
|
const task3 = new taskbuffer.Task({
|
||||||
taskFunction: async () => {
|
taskFunction: async () => {
|
||||||
await smartdelay.delayFor(2000);
|
await smartdelay.delayFor(2000);
|
||||||
task3Executed = true;
|
task3Executed = true;
|
||||||
@ -29,11 +29,11 @@ let task3 = new taskbuffer.Task({
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('expect run tasks in sequence', async () => {
|
tap.test('expect run tasks in sequence', async () => {
|
||||||
let testTaskchain = new taskbuffer.Taskchain({
|
const testTaskchain = new taskbuffer.Taskchain({
|
||||||
name: 'Taskchain1',
|
name: 'Taskchain1',
|
||||||
taskArray: [task1, task2, task3]
|
taskArray: [task1, task2, task3]
|
||||||
});
|
});
|
||||||
let testPromise = testTaskchain.trigger();
|
const testPromise = testTaskchain.trigger();
|
||||||
await smartdelay.delayFor(2100);
|
await smartdelay.delayFor(2100);
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(task1Executed).to.be.true;
|
expect(task1Executed).to.be.true;
|
||||||
|
40
test/test.7.taskloop.ts
Normal file
40
test/test.7.taskloop.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
import * as taskbuffer from '../ts';
|
||||||
|
|
||||||
|
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 :)');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
afterTask = new taskbuffer.Task({
|
||||||
|
name: 'myAfterTask',
|
||||||
|
taskFunction: async () => {
|
||||||
|
console.log('afterTask executed :)');
|
||||||
|
},
|
||||||
|
preTask,
|
||||||
|
afterTask
|
||||||
|
});
|
||||||
|
|
||||||
|
mainTask = new taskbuffer.Task({
|
||||||
|
name: 'mainTask',
|
||||||
|
taskFunction: async () => {
|
||||||
|
console.log('main task executed');
|
||||||
|
},
|
||||||
|
preTask,
|
||||||
|
afterTask
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should execute the mainTasj', async () => {
|
||||||
|
await mainTask.trigger();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
Loading…
Reference in New Issue
Block a user