-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
63 lines (51 loc) · 1.77 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*!
* minibase-control-flow <https://github.com/node-minibase/minibase-control-flow>
*
* Copyright (c) Charlike Mike Reagent <@tunnckoCore> (http://i.am.charlike.online)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
var assert = require('assert')
var isPromise = require('is-promise')
var MiniBase = require('minibase').MiniBase
var minitest = require('minibase-tests')
var plugin = require('./index')
var suite = minitest(MiniBase)
suite.addTest('should have `.parallel`, `.serial` and `.each` methods', function () {
var app = new MiniBase()
app.use(plugin())
assert.strictEqual(typeof app.each, 'function')
assert.strictEqual(typeof app.serial, 'function')
assert.strictEqual(typeof app.parallel, 'function')
return Promise.resolve()
})
suite.addTest('should both methods return promises', function () {
var base = new MiniBase()
base.use(plugin())
var p1 = base.serial([Promise.resolve(11)], function noop () {})
var p2 = base.parallel(['foo', Promise.resolve(22), 33])
var p3 = base.each([1, Promise.reject(new Error('foo')), 'qux'])
assert.strictEqual(isPromise(p1), true)
assert.strictEqual(isPromise(p2), true)
assert.strictEqual(isPromise(p3), true)
return Promise.resolve()
})
suite.runTests().then(function (result) {
if (result.length) {
result.forEach(function (test) {
console.log('not ok', test.index, test.title)
console.log(' ---')
console.log(test.reason.stack.split('\n').slice(0, 4).map((line) => {
return ' ' + line
}).join('\n'))
console.log(' ...')
})
return
}
// all tests count
console.log('# tests', result.tests)
// all tests minus errored tests is passed tests count
console.log('# pass', result.tests - result.length)
console.log('# ok')
})