-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
37 lines (31 loc) · 1.05 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { assert } = require("chai");
const { usePipeline } = require("./lib/index");
describe('The basic test to ensure that pipeline is working...', function(){
it('First...', () =>
{
function someObject(){
this.test = false;
}
const value = new someObject();
const pipeline = usePipeline((x, next) => { x.test = true; next(); })
.pipe((x, next) => { x.test = false; next(); })
.pipe((x, next) => { x.test = true; });
pipeline.run(value);
assert.isTrue(value.test);
});
it('Second...', () =>
{
function someObject(){
this.test = null;
this.times = 0;
}
const value = new someObject();
usePipeline((x, next) => { x.test = 11; x.times++; next(); })
.pipe((x, next) => { x.test = "data"; x.times++; })
.pipe((x, next) => { x.test = true; x.times++; })
.run(value);
assert.isNotNull(value.test);
assert.isString(value.test);
assert.equal(value.times, 2);
});
});