-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
43 lines (38 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
38
39
40
41
42
43
/*!
* vez <https://github.com/tunnckoCore/vez>
*
* Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
var test = require('assertit')
var vez = require('./index')
var Bluebird = require('bluebird')
test('vez:', function (done) {
vez()
.use(Bluebird.resolve(123))
.use(function () {
test.deepEqual(this, {a: 'b', c: 'd', e: 'f'})
return Bluebird.resolve(456)
})
.use(function (foo, next) {
test.deepEqual(this, {a: 'b', c: 'd', e: 'f'})
next(null, foo, 789)
})
.use(function * (first, second) {
this.g = first + second
test.deepEqual(this, {a: 'b', c: 'd', e: 'f', g: 1245})
return yield {
gens: this.g
}
})
.run({a: 'b'}, {c: 'd'}, {e: 'f'}, function (err, res) {
if (err) {
return console.error(err)
}
test.deepEqual(this, {a: 'b', c: 'd', e: 'f', g: 1245})
test.deepEqual(res, [123, 456, [ 456, 789 ], { gens: 1245 }])
done()
})
})