-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.js
40 lines (35 loc) · 818 Bytes
/
example.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
// Load test runner and your app
const doTest = require( 'dotest' );
const app = {
methodOne: callback => {
var data = {
music: ['song'],
};
callback( null, data );
},
sub: {
methodTwo: () => {},
},
};
// Check app interface
doTest.add( 'App interface', test => {
test()
.isFunction( 'fail', 'methodOne', app.methodOne )
.isObject( 'fail', 'sub', app.sub )
.isFunction( 'fail', 'sub.methodTwo', app.sub.methodTwo )
.done()
;
} );
// Check method response
doTest.add( 'App methodOne', test => {
app.methodOne( ( err, data ) => {
test( err )
.isObject( 'fail', 'Callback data', data )
.isArray( 'fail', 'data.music', data.music )
.isNotEmpty( 'warn', 'data.music', data.music )
.done()
;
} );
} );
// Run the tests
doTest.run();