diff --git a/README.md b/README.md index 9a1387d..1d3ce5e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [coone][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] -> Acts like [co@3](https://github.com/tj/co/tree/93fd2bb5e8803fdde15d95b3025b0b134904f4dc), on top of [always-done](https://github.com/hybridables/always-done). But accept everything, not only generators - sync functions, async functions, callbacks and more. Flow-control for now and then. +> Acts like [co@4](https://github.com/tj/co/tree/93fd2bb5e8803fdde15d95b3025b0b134904f4dc) and also is drop-in replacement for it. Built on top of [merz](https://github.com/hybridables/merz), actually thanks to [always-done](https://github.com/hybridables/always-done). But accept everything, not only generators - sync functions, async functions, callbacks and more. Flow-control for now and then. [![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url] diff --git a/package.json b/package.json index ba8625c..55f85dc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coone", "version": "0.0.0", - "description": "Acts like `co3`, on top of `always-done`. But accept everything, not only generators - sync functions, async functions, callbacks and more. Flow-control for now and then.", + "description": "Acts like `co@3` and also is drop-in replacement for it. Built on top of `merz`, actually thanks to `always-done`. But accept everything, not only generators - sync functions, async functions, callbacks and more. Flow-control for now and then.", "repository": "hybridables/coone", "author": "Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)", "main": "index.js", @@ -18,6 +18,7 @@ "bluebird": "^2.10.1", "mz": "^2.0.0", "rx": "^4.0.0", + "semver": "^5.0.3", "simple-get": "^1.4.3", "through2": "^2.0.0" }, diff --git a/test.js b/test.js index 0270711..dc5a4e6 100644 --- a/test.js +++ b/test.js @@ -10,6 +10,7 @@ 'use strict' var test = require('assertit') +var semver = require('semver') test('errors', function (done) { require('./test/errors') @@ -45,3 +46,10 @@ test('child processes', function (done) { require('./test/child_processes') done() }) + +if (semver.gte(process.version, '0.11.13')) { + test('generators', function (done) { + require('./test/generators') + done() + }) +} diff --git a/test/generators.js b/test/generators.js new file mode 100644 index 0000000..a978259 --- /dev/null +++ b/test/generators.js @@ -0,0 +1,41 @@ +/*! + * 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() + }) +})