1 | const assert = require('assert');
|
2 | const co = require('../cockrel');
|
3 |
|
4 |
|
5 |
|
6 | describe("Plugin: as", function() {
|
7 |
|
8 |
|
9 | it("can execute a sub-chain and add it's value as key", function(done) {
|
10 |
|
11 | co.as('flibble', co.do((data) => { return 'potato'; }))
|
12 | .do(check)
|
13 | .begin({test : 1});
|
14 |
|
15 |
|
16 | function check(data) {
|
17 | assert.equal(data.test, 1);
|
18 | assert.equal(data.flibble, 'potato');
|
19 | done();
|
20 | }
|
21 |
|
22 | });
|
23 |
|
24 | it("can handle a non object previous value", function(done) {
|
25 |
|
26 | co.as('flibble', co.do((data) => { return 'potato'; }))
|
27 | .do(check)
|
28 | .begin([1,4]);
|
29 |
|
30 |
|
31 | function check(data) {
|
32 | assert.equal(data.previous[0], 1);
|
33 | assert.equal(data.previous[1], 4);
|
34 | assert.equal(data.flibble, 'potato');
|
35 | done();
|
36 | }
|
37 |
|
38 | });
|
39 |
|
40 |
|
41 |
|
42 | });
|
43 |
|
44 |
|