Skip to content

Commit

Permalink
Docs(readme): Added Promise example
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdm committed Dec 26, 2019
1 parent 55f30c1 commit adb9f92
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,42 @@ const doTest = require ('dotest');
const app = require ('./');

// Check app interface
doTest.add ('App interface', (test) => {
doTest.add ('App interface', test => {
test()
.isFunction ('fail', 'methodOne', app.methodOne)
.isObject ('fail', 'sub', app.sub)
.isFunction ('fail', 'sub.methodTwo', app.sub.methodTwo)
.done();
.done()
;
});

// Check method response
doTest.add ('App methodOne', (test) => {
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();
.done()
;
});
});

// Check promise
doTest.add ('Promise good', async test => {
try {
const data = await myPromise();

test()
.isObject ('fail', 'data', data)
.done()
;
}
catch (err) {
test (err).done();
}
});

// Run the tests
doTest.run();
```
Expand Down

0 comments on commit adb9f92

Please sign in to comment.