fix(tests): now using tstest

This commit is contained in:
2018-08-04 17:53:22 +02:00
parent df18aba4b5
commit f60deddadd
37 changed files with 1607 additions and 1659 deletions

View File

@@ -1,63 +1,58 @@
// TaskChain chains tasks
// and extends Task
import * as plugins from './taskbuffer.plugins'
import { Task } from './taskbuffer.classes.task'
import helpers = require('./taskbuffer.classes.helpers')
import * as plugins from './taskbuffer.plugins';
import { Task } from './taskbuffer.classes.task';
import helpers = require('./taskbuffer.classes.helpers');
export class Taskchain extends Task {
taskArray: Task[]
private _oraObject
taskArray: Task[];
constructor(optionsArg: {
taskArray: Task[],
name?: string,
log?: boolean,
buffered?: boolean,
bufferMax?: number
taskArray: Task[];
name?: string;
log?: boolean;
buffered?: boolean;
bufferMax?: number;
}) {
let options = plugins.lodash.merge(
{
let options = {
...{
name: 'unnamed Taskchain',
log: false
},
optionsArg,
{
taskFunction: (x: any) => { // this is the function that gets executed when TaskChain is triggered
let done = plugins.q.defer() // this is the starting Deferred object
let taskCounter = 0 // counter for iterating async over the taskArray
let iterateTasks = (x) => {
if (typeof this.taskArray[ taskCounter ] !== 'undefined') {
this._oraObject.text(this.name + ' running: Task' + this.taskArray[ taskCounter ].name)
this.taskArray[ taskCounter ].trigger(x)
.then((x) => {
plugins.beautylog.ok(this.taskArray[ taskCounter ].name)
taskCounter++
iterateTasks(x)
})
...optionsArg,
...{
taskFunction: (x: any) => {
// this is the function that gets executed when TaskChain is triggered
let done = plugins.smartpromise.defer(); // this is the starting Deferred object
let taskCounter = 0; // counter for iterating async over the taskArray
let iterateTasks = x => {
if (typeof this.taskArray[taskCounter] !== 'undefined') {
console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
this.taskArray[taskCounter].trigger(x).then(x => {
plugins.smartlog.defaultLogger.info(this.taskArray[taskCounter].name);
taskCounter++;
iterateTasks(x);
});
} else {
this._oraObject.endOk('Taskchain "' + this.name + '" completed successfully')
done.resolve(x)
console.log('Taskchain "' + this.name + '" completed successfully');
done.resolve(x);
}
}
iterateTasks(x)
return done.promise
};
iterateTasks(x);
return done.promise;
}
}
)
super(options)
this.taskArray = optionsArg.taskArray
this._oraObject = plugins.beautylog.ora
if (optionsArg.log === true) {
this._oraObject.start()
}
};
super(options);
this.taskArray = optionsArg.taskArray;
}
addTask (taskArg: Task) {
this.taskArray.push(taskArg)
addTask(taskArg: Task) {
this.taskArray.push(taskArg);
}
removeTask (taskArg: Task) {
removeTask(taskArg: Task) {
// TODO:
}
shiftTask () {
shiftTask() {
// TODO:
}
}