1 |
|
2 | const assert = require('assert');
|
3 | const co = require('../cockrel');
|
4 |
|
5 |
|
6 |
|
7 | describe("Plugin: end", function() {
|
8 |
|
9 |
|
10 | it("terminates a chain as an error", function(done) {
|
11 | co
|
12 | .end()
|
13 | .do(antiCheck)
|
14 | .begin(123)
|
15 | .catch(check);
|
16 |
|
17 | function antiCheck(data) {
|
18 | throw new Error('Should never have reached here!');
|
19 | }
|
20 |
|
21 | function check(error) {
|
22 | assert.equal(error, 123);
|
23 | done();
|
24 | }
|
25 |
|
26 | });
|
27 |
|
28 | it("terminates a chain as a success", function(done) {
|
29 | co
|
30 | .end(true)
|
31 | .do(antiCheck)
|
32 | .begin(123)
|
33 | .then(check, antiCheck);
|
34 |
|
35 | function antiCheck(data) {
|
36 | throw new Error('Should never have reached here!');
|
37 | }
|
38 |
|
39 | function check(error) {
|
40 | assert.equal(error, 123);
|
41 | done();
|
42 | }
|
43 |
|
44 | });
|
45 |
|
46 |
|
47 |
|
48 | });
|