Skip to content

Commit

Permalink
fix(tests): update tests, use "minibase-tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Nov 14, 2016
1 parent 2db70be commit 381c1d1
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 28 deletions.
17 changes: 8 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ utils.delegate(MiniBase.prototype, {
this.define('_eventsCount', this._eventsCount)
this.define('_anonymousPluginsCount', 1)

// default error handlers
this.once('error', this.options.silent === true
? function onerrorSilent () {}
: function onerror (err) {
console.log('minibase`s default error listener:')
console.error(err.stack || err)
console.log('Pass options.silent: true to disable')
})

return this
},

Expand Down Expand Up @@ -235,6 +226,14 @@ utils.delegate(MiniBase.prototype, {
*/

use: function use (fn) {
/* istanbul ignore next */
if (!this.listeners('error').length && this.options.silent !== true) {
this.once('error', function defaultErrorHandler (err) {
console.log('MiniBase default error handler:', err.toString())
console.log(err.stack)
})
}

utils.tryCatchCallback.call(this, fn, {
passCallback: false,
args: [this]
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "npm run coverage",
"posttest": "npm run lint:coverage",
"coverage": "nyc node test.js",
"lint:coverage": "nyc check-coverage --lines 0 --branches 0 --statements 0 --functions 0",
"lint:coverage": "nyc check-coverage --lines 100 --branches 100 --statements 100 --functions 100",
"report-coverage": "nyc report --reporter=text-lcov | coveralls",
"prerelease": "npm test",
"release": "standard-version --sign --no-verify",
Expand All @@ -34,7 +34,8 @@
"devDependencies": {
"commitizen": "~2.7.0",
"coveralls": "^2.11.15",
"cz-conventional-changelog": "^1.2.0",
"cz-conventional-changelog": "1.1.5",
"minibase-tests": "^1.0.3",
"mukla": "^0.4.8",
"nyc": "^8.1.0",
"pre-commit": "^1.1.3",
Expand Down
23 changes: 8 additions & 15 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@

'use strict'

var assert = require('assert')
var MiniBase = require('./index').MiniBase
var app = new MiniBase({
silent: true
})
var suite = require('minibase-tests')

// uncomment to handle the errors,
// even if `silent: true`
//
app.once('error', function (err) {
console.log(err.fnName) // => anonymous 1
suite(MiniBase).runTests().then(function (res) {
assert.strictEqual(res.length, 18)
console.log('all `minibase-tests` passed')
}, function (err) {
console.error('fail:')
console.error(err.stack || err)
})

app.use(function (ctx) {
console.log(ctx)
console.log(this)
})
app.use(function (ctx) {
console.log(tdhdasdasdis) // eslint-disable-line no-undef
})
101 changes: 99 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ asn1@~0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86"

assert-kindof@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/assert-kindof/-/assert-kindof-2.0.0.tgz#4fb62f5bf0b708cab4834b7973dbd52bdac8cec5"
dependencies:
clean-stacktrace "^1.0.0"
is-kindof "^3.0.0"
kind-of-extra "^1.0.4"
lazy-cache "^2.0.1"
string-template "^1.0.0"

assert-plus@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"
Expand Down Expand Up @@ -253,6 +263,10 @@ bl@~1.1.2:
dependencies:
readable-stream "~2.0.5"

bluebird@^3.4.6:
version "3.4.6"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.6.tgz#01da8d821d87813d158967e743d5fe6c62cf8c0f"

boom@2.x.x:
version "2.10.1"
resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f"
Expand Down Expand Up @@ -826,6 +840,14 @@ duplexer2@0.0.2:
dependencies:
readable-stream "~1.1.9"

each-promise@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/each-promise/-/each-promise-1.0.2.tgz#7ae12732410e7af41c4856f328de6d4c4a9ea715"
dependencies:
extend-shallow "^2.0.1"
lazy-cache "^2.0.2"
native-promise "^1.0.1"

ecc-jsbn@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
Expand Down Expand Up @@ -1719,6 +1741,23 @@ is-error@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/is-error/-/is-error-2.2.1.tgz#684a96d84076577c98f4cdb40c6d26a5123bf19c"

is-es6-generator-function@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-es6-generator-function/-/is-es6-generator-function-1.0.0.tgz#fb7f8ca143d90b63d248fb30a396f6f79aa5db7b"
dependencies:
is-generator-function-name "~1.0.0"

is-es6-generator@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-es6-generator/-/is-es6-generator-1.0.0.tgz#6af4582dd42b0f8b0f09b2cdcce7c8a33015da7e"

is-es6-generators@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-es6-generators/-/is-es6-generators-1.0.2.tgz#c0b5bb6c05902a504df57e63c0825e7054c72218"
dependencies:
is-es6-generator "~1.0.0"
is-es6-generator-function "~1.0.0"

is-extendable@^0.1.0, is-extendable@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
Expand All @@ -1743,12 +1782,24 @@ is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"

is-generator-function-name@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-generator-function-name/-/is-generator-function-name-1.0.0.tgz#254fff9ff56b5dd9a78c129453ab19e593b62f3e"

is-glob@^2.0.0, is-glob@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863"
dependencies:
is-extglob "^1.0.0"

is-kindof@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-kindof/-/is-kindof-3.0.1.tgz#71100c851543e559905e62d1935b022ae9b5eb96"
dependencies:
kind-of-extra "^1.0.4"
kind-of-types "^1.0.1"
lazy-cache "^2.0.1"

is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4:
version "2.15.0"
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b"
Expand Down Expand Up @@ -2022,7 +2073,21 @@ jsx-ast-utils@^1.3.1:
acorn-jsx "^3.0.1"
object-assign "^4.1.0"

kind-of@^3.0.2, kind-of@^3.0.3:
kind-of-extra@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/kind-of-extra/-/kind-of-extra-1.0.4.tgz#34f9ad35ce4854a59c50ec212cdf6d4b7bf93edf"
dependencies:
is-es6-generators "^1.0.2"
is-node-stream "^1.0.0"
is-promise "^2.1.0"
kind-of "^3.0.4"
lazy-cache "^2.0.1"

kind-of-types@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/kind-of-types/-/kind-of-types-1.0.1.tgz#f03d3010f0388e8cd2ff6c90b0965ef49f71a778"

kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.0.4.tgz#7b8ecf18a4e17f8269d73b501c9f232c96887a74"
dependencies:
Expand All @@ -2039,7 +2104,7 @@ lazy-cache@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"

lazy-cache@^2.0.0, lazy-cache@^2.0.1:
lazy-cache@^2.0.0, lazy-cache@^2.0.1, lazy-cache@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-2.0.2.tgz#b9190a4f913354694840859f8a8f7084d8822264"
dependencies:
Expand Down Expand Up @@ -2319,6 +2384,30 @@ mime-types@^2.1.11, mime-types@~2.1.7:
dependencies:
mime-db "~1.24.0"

minibase-tests@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minibase-tests/-/minibase-tests-1.0.1.tgz#1c6027276d1817844d8a81f359761d1ab882c06a"
dependencies:
assert-kindof "^2.0.0"
bluebird "^3.4.6"
each-promise "^1.0.2"
eventemitter3 "^2.0.2"
minibase "*"

minibase@*:
version "0.4.5"
resolved "https://registry.yarnpkg.com/minibase/-/minibase-0.4.5.tgz#fa20c4a96cd70aed8e678180fbf20e7a29a03926"
dependencies:
define-property "^0.2.5"
delegate-properties "^0.4.0"
eventemitter3 "^2.0.2"
extend-shallow "^2.0.1"
get-fn-name "^1.0.0"
isobject "^2.1.0"
lazy-cache "^2.0.1"
static-extend "^0.1.2"
try-catch-callback "^2.0.0"

minimatch@^2.0.1:
version "2.0.10"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7"
Expand Down Expand Up @@ -2387,6 +2476,10 @@ mute-stream@0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0"

native-promise@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/native-promise/-/native-promise-1.0.1.tgz#6d7e9d06c3d45f51c5306da3400b7e91a5f8890e"

natives@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31"
Expand Down Expand Up @@ -3093,6 +3186,10 @@ string_decoder@~0.10.x:
version "0.10.31"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"

string-template@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/string-template/-/string-template-1.0.0.tgz#9e9f2233dc00f218718ec379a28a5673ecca8b96"

string-width@^1.0.1, string-width@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
Expand Down

0 comments on commit 381c1d1

Please sign in to comment.