1 | const assert = require('assert');
|
2 | const co = require('../cockrel');
|
3 |
|
4 |
|
5 |
|
6 | describe("Plugin: when", function() {
|
7 |
|
8 |
|
9 | it("can execute a sub-chain conditionally", function(done) {
|
10 |
|
11 | co.when('test == 1', co.pick({ foo : 'bar'}))
|
12 | .do(check)
|
13 | .begin({test: 1});
|
14 |
|
15 | function check(data) {
|
16 | assert.equal(data.foo, 'bar');
|
17 | done();
|
18 | }
|
19 |
|
20 | });
|
21 |
|
22 | it("can not execute a sub-chain conditionally", function(done) {
|
23 |
|
24 | co.when('test != 1', co.pick({ foo : 'bar'}))
|
25 | .do(check)
|
26 | .begin({test: 1});
|
27 |
|
28 | function check(data) {
|
29 | assert.equal(data.test, 1);
|
30 | done();
|
31 | }
|
32 |
|
33 | });
|
34 |
|
35 | });
|
36 |
|
37 |
|