-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tunnckoCore
committed
Oct 1, 2015
1 parent
a9a822c
commit 5b1ca83
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*! | ||
* coone <https://github.com/hybridables/coone> | ||
* | ||
* Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk) | ||
* Released under the MIT license. | ||
*/ | ||
|
||
/* jshint asi:true */ | ||
|
||
'use strict' | ||
|
||
var mzfs = require('mz/fs') | ||
var test = require('assertit') | ||
var coone = require('../index') | ||
|
||
function * success () { | ||
return yield mzfs.readFile('package.json', 'utf8') | ||
} | ||
|
||
function * failure () { | ||
return yield mzfs.readFile('foobar.json') | ||
} | ||
|
||
test('should handle successful generator function', function (done) { | ||
coone(success)(function (err, res) { | ||
test.ifError(err) | ||
test.strictEqual(typeof res, 'string') | ||
test.ok(res.indexOf('"license": "MIT"') !== -1) | ||
done() | ||
}) | ||
}) | ||
|
||
test('should handle generator function errors', function (done) { | ||
coone(failure)(function (err, res) { | ||
test.ifError(!err) | ||
test.ok(err instanceof Error) | ||
test.strictEqual(err.code, 'ENOENT') | ||
test.strictEqual(res, undefined) | ||
done() | ||
}) | ||
}) |