☕️ Classic, reliable, trusted test framework for Node.js and the browser
reorganize test hierarchy; closes #2838
Christopher Hillerf20de56637b2
diff --git a/Makefile b/Makefileindex ad8b097e..2fa367e8 100644--- a/Makefile+++ b/Makefile@@ -63,79 +63,79 @@ test-jsapi:test-unit:@printf "==> [Test :: Unit]\n"- $(call test_node,unit) test/acceptance/*.js \- --growl \- test/*.js+ $(call test_node,unit) test/unit/*.spec.js \+ test/node-unit/*.spec.js \+ --growltest-integration:@printf "==> [Test :: Integrations]\n"$(call test_node,integration) --timeout 5000 \- test/integration/*.js+ test/integration/*.spec.jstest-compilers:@printf "==> [Test :: Compilers]\n"$(call test_node,compilers) --compilers coffee:coffee-script/register,foo:./test/compiler/foo \- test/acceptance/test.coffee \- test/acceptance/test.foo+ test/compiler/test.coffee \+ test/compiler/test.footest-requires:@printf "==> [Test :: Requires]\n"$(call test_node,requires) --compilers coffee:coffee-script/register \- --require test/acceptance/require/a.js \- --require test/acceptance/require/b.coffee \- --require test/acceptance/require/c.js \- --require test/acceptance/require/d.coffee \- test/acceptance/require/require.spec.js+ --require test/require/a.js \+ --require test/require/b.coffee \+ --require test/require/c.js \+ --require test/require/d.coffee \+ test/require/require.spec.jstest-bdd:@printf "==> [Test :: BDD]\n"$(call test_node,bdd) --ui bdd \- test/acceptance/interfaces/bdd.spec+ test/interfaces/bdd.spectest-tdd:@printf "==> [Test :: TDD]\n"$(call test_node,tdd) --ui tdd \- test/acceptance/interfaces/tdd.spec+ test/interfaces/tdd.spectest-qunit:@printf "==> [Test :: QUnit]\n"$(call test_node,qunit) --ui qunit \- test/acceptance/interfaces/qunit.spec+ test/interfaces/qunit.spectest-exports:@printf "==> [Test :: Exports]\n"$(call test_node,exports) --ui exports \- test/acceptance/interfaces/exports.spec+ test/interfaces/exports.spectest-glob:@printf "==> [Test :: Glob]\n"- bash ./test/acceptance/glob/glob.sh+ bash ./test/glob/glob.shtest-reporters:@printf "==> [Test :: Reporters]\n"- $(call test_node,reporters) test/reporters/*.js+ $(call test_node,reporters) test/reporters/*.spec.jstest-only:@printf "==> [Test :: Only]\n"$(call test_node,only-tdd) --ui tdd \- test/acceptance/misc/only/tdd.spec+ test/misc/only/tdd.spec$(call test_node,only-bdd) --ui bdd \- test/acceptance/misc/only/bdd.spec+ test/misc/only/bdd.spec$(call test_node,only-bdd-require) --ui qunit \- test/acceptance/misc/only/bdd-require.spec+ test/misc/only/bdd-require.spectest-global-only:@printf "==> [Test :: Global Only]\n"$(call test_node,global-only-tdd) --ui tdd \- test/acceptance/misc/only/global/tdd.spec+ test/misc/only/global/tdd.spec$(call test_node,global-only-bdd) --ui bdd \- test/acceptance/misc/only/global/bdd.spec+ test/misc/only/global/bdd.spec$(call test_node,global-only-qunit) --ui qunit \- test/acceptance/misc/only/global/qunit.spec+ test/misc/only/global/qunit.spectest-mocha:@printf "==> [Test :: Mocha]\n"@@ -144,19 +144,19 @@ test-mocha:non-tty:@printf "==> [Test :: Non-TTY]\n"$(call test_node,non-tty-dot) --reporter dot \- test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/dot.out+ test/interfaces/bdd.spec 2>&1 > /tmp/dot.out@echo dot:@cat /tmp/dot.out$(call test_node,non-tty-list) --reporter list \- test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/list.out+ test/interfaces/bdd.spec 2>&1 > /tmp/list.out@echo list:@cat /tmp/list.out$(call test_node,non-tty-spec) --reporter spec \- test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/spec.out+ test/interfaces/bdd.spec 2>&1 > /tmp/spec.out@echo spec:@cat /tmp/spec.outdiff --git a/karma.conf.js b/karma.conf.jsindex 2ba9d4d2..c99150e2 100644--- a/karma.conf.js+++ b/karma.conf.js@@ -18,14 +18,7 @@ module.exports = function (config) {// we use the BDD interface for all of the tests that// aren't interface-specific.'test/browser-fixtures/bdd.fixture.js',- 'test/acceptance/*.spec.js'- ],- exclude: [- 'test/acceptance/http.spec.js',- 'test/acceptance/fs.spec.js',- 'test/acceptance/file-utils.spec.js',- 'test/acceptance/require/**/*.js',- 'test/acceptance/misc/**/*.js'+ 'test/unit/*.spec.js'],preprocessors: {'test/**/*.js': ['browserify']@@ -128,7 +121,7 @@ module.exports = function (config) {}cfg.files = ['test/browser-fixtures/' + ui + '.fixture.js',- 'test/acceptance/interfaces/' + ui + '.spec.js'+ 'test/interfaces/' + ui + '.spec.js'];} else if (cfg.sauceLabs) {cfg.sauceLabs.testName = 'Unit Tests';diff --git a/test/browser-fixtures/bdd.fixture.js b/test/browser-fixtures/bdd.fixture.jsindex d1999367..5fe802f7 100644--- a/test/browser-fixtures/bdd.fixture.js+++ b/test/browser-fixtures/bdd.fixture.js@@ -2,5 +2,7 @@/* eslint-env browser */+process.stdout = require('browser-stdout')();+window.mocha.timeout(200).ui('bdd');diff --git a/test/browser-fixtures/exports.fixture.js b/test/browser-fixtures/exports.fixture.jsindex 97b8b97c..a4c25cff 100644--- a/test/browser-fixtures/exports.fixture.js+++ b/test/browser-fixtures/exports.fixture.js@@ -2,5 +2,7 @@/* eslint-env browser */+process.stdout = require('browser-stdout')();+window.mocha.timeout(200).ui('exports');diff --git a/test/browser-fixtures/qunit.fixture.js b/test/browser-fixtures/qunit.fixture.jsindex a3fd8879..79b49498 100644--- a/test/browser-fixtures/qunit.fixture.js+++ b/test/browser-fixtures/qunit.fixture.js@@ -2,5 +2,7 @@/* eslint-env browser */+process.stdout = require('browser-stdout')();+window.mocha.timeout(200).ui('qunit');diff --git a/test/browser-fixtures/tdd.fixture.js b/test/browser-fixtures/tdd.fixture.jsindex 0c36f0c5..2fdc8f75 100644--- a/test/browser-fixtures/tdd.fixture.js+++ b/test/browser-fixtures/tdd.fixture.js@@ -2,5 +2,7 @@/* eslint-env browser */+process.stdout = require('browser-stdout')();+window.mocha.timeout(200).ui('tdd');diff --git a/test/browser/README.md b/test/browser/README.mdnew file mode 100644index 00000000..15e4178b--- /dev/null+++ b/test/browser/README.md@@ -0,0 +1,3 @@+These files need to be run manually by loading the `.html` file(s) in a browser.++It would be awesome if we could automate that!diff --git a/test/acceptance/test.coffee b/test/compiler/test.coffeesimilarity index 100%rename from test/acceptance/test.coffeerename to test/compiler/test.coffeediff --git a/test/acceptance/test.foo b/test/compiler/test.foosimilarity index 100%rename from test/acceptance/test.foorename to test/compiler/test.foodiff --git a/test/acceptance/glob/glob.sh b/test/glob/glob.shsimilarity index 84%rename from test/acceptance/glob/glob.shrename to test/glob/glob.shindex 823ba07f..c0cb21d3 100755--- a/test/acceptance/glob/glob.sh+++ b/test/glob/glob.sh@@ -7,7 +7,7 @@ cd $SCRIPT_DIR || {exit 1}-../../../bin/mocha -R json-stream ./*.js > /tmp/mocha-glob.txt || {+../../bin/mocha -R json-stream ./*.js > /tmp/mocha-glob.txt || {echo Globbing ./*.js in `pwd` failed.exit 1}@@ -17,7 +17,7 @@ cat /tmp/mocha-glob.txt | grep -q -F '["end",{"suites":1,"tests":1,"passes":1,"pexit 1}-../../../bin/mocha -R json-stream ./*-none.js 2> /tmp/mocha-glob.txt && {+../../bin/mocha -R json-stream ./*-none.js 2> /tmp/mocha-glob.txt && {echo Globbing './*-none.js' in `pwd` failed.exit 1}@@ -27,7 +27,7 @@ cat /tmp/mocha-glob.txt | grep -q -F 'Could not find any test files matching patexit 1}-../../../bin/mocha -R json-stream ./*.js ./*-none.js >& /tmp/mocha-glob.txt || {+../../bin/mocha -R json-stream ./*.js ./*-none.js >& /tmp/mocha-glob.txt || {echo Globbing ./*.js ./*-none.js in `pwd` failed.exit 1}@@ -43,7 +43,7 @@ cat /tmp/mocha-glob.txt | grep -q -F 'Could not find any test files matching pat# In windows, the shell passes globs unexpanded, executables do expansion if they support it.# Adding single-quotes around the glob below makes bash pass glob unexpanded,# allowing us to test windows-style globbing in bash.-../../../bin/mocha -R json-stream './*.js' > /tmp/mocha-glob.txt || {+../../bin/mocha -R json-stream './*.js' > /tmp/mocha-glob.txt || {echo Globbing './*.js' in `pwd` failed.exit 1}@@ -53,7 +53,7 @@ cat /tmp/mocha-glob.txt | grep -q -F '["end",{"suites":1,"tests":1,"passes":1,"pexit 1}-../../../bin/mocha -R json-stream './*-none.js' 2> /tmp/mocha-glob.txt && {+../../bin/mocha -R json-stream './*-none.js' 2> /tmp/mocha-glob.txt && {echo Globbing './*-none.js' in `pwd` failed.exit 1}diff --git a/test/acceptance/glob/glob.spec.js b/test/glob/glob.spec.jssimilarity index 100%rename from test/acceptance/glob/glob.spec.jsrename to test/glob/glob.spec.jsdiff --git a/test/acceptance/interfaces/bdd.spec.js b/test/interfaces/bdd.spec.jssimilarity index 100%rename from test/acceptance/interfaces/bdd.spec.jsrename to test/interfaces/bdd.spec.jsdiff --git a/test/acceptance/interfaces/exports.spec.js b/test/interfaces/exports.spec.jssimilarity index 100%rename from test/acceptance/interfaces/exports.spec.jsrename to test/interfaces/exports.spec.jsdiff --git a/test/acceptance/interfaces/qunit.spec.js b/test/interfaces/qunit.spec.jssimilarity index 100%rename from test/acceptance/interfaces/qunit.spec.jsrename to test/interfaces/qunit.spec.jsdiff --git a/test/acceptance/interfaces/tdd.spec.js b/test/interfaces/tdd.spec.jssimilarity index 100%rename from test/acceptance/interfaces/tdd.spec.jsrename to test/interfaces/tdd.spec.jsdiff --git a/test/jsapi/index.js b/test/jsapi/index.jsindex 42133578..430a2052 100644--- a/test/jsapi/index.js+++ b/test/jsapi/index.js@@ -12,16 +12,16 @@ var mocha = new Mocha({// mocha.reporter('spec');require('should');-mocha.addFile('test/suite.spec.js');-mocha.addFile('test/runner.spec.js');-mocha.addFile('test/runnable.spec.js');-mocha.addFile('test/hook-sync.spec.js');-mocha.addFile('test/hook-sync-nested.spec.js');-mocha.addFile('test/hook-async.spec.js');-mocha.addFile('test/acceptance/duration.spec.js');-mocha.addFile('test/acceptance/fs.spec.js');-mocha.addFile('test/acceptance/globals.spec.js');-mocha.addFile('test/acceptance/timeout.spec.js');+mocha.addFile('test/unit/suite.spec.js');+mocha.addFile('test/unit/runner.spec.js');+mocha.addFile('test/unit/runnable.spec.js');+mocha.addFile('test/unit/hook-sync.spec.js');+mocha.addFile('test/unit/hook-sync-nested.spec.js');+mocha.addFile('test/unit/hook-async.spec.js');+mocha.addFile('test/unit/duration.spec.js');+mocha.addFile('test/node-unit/fs.spec.js');+mocha.addFile('test/unit/globals.spec.js');+mocha.addFile('test/unit/timeout.spec.js');mocha.run(function () {console.log('done');diff --git a/test/acceptance/misc/exit.spec.js b/test/misc/exit.spec.jssimilarity index 100%rename from test/acceptance/misc/exit.spec.jsrename to test/misc/exit.spec.jsdiff --git a/test/acceptance/misc/many.spec.js b/test/misc/many.spec.jssimilarity index 100%rename from test/acceptance/misc/many.spec.jsrename to test/misc/many.spec.jsdiff --git a/test/acceptance/misc/nontty.spec.js b/test/misc/nontty.spec.jssimilarity index 100%rename from test/acceptance/misc/nontty.spec.jsrename to test/misc/nontty.spec.jsdiff --git a/test/acceptance/misc/only/bdd-require.spec.js b/test/misc/only/bdd-require.spec.jssimilarity index 90%rename from test/acceptance/misc/only/bdd-require.spec.jsrename to test/misc/only/bdd-require.spec.jsindex 14710c4c..1c90d7ac 100644--- a/test/acceptance/misc/only/bdd-require.spec.js+++ b/test/misc/only/bdd-require.spec.js@@ -2,7 +2,7 @@/* jshint node: true */-var mocha = require('../../../../lib/mocha');+var mocha = require('../../../lib/mocha');var beforeEach = mocha.beforeEach;var it = mocha.it;diff --git a/test/acceptance/misc/only/bdd.spec.js b/test/misc/only/bdd.spec.jssimilarity index 100%rename from test/acceptance/misc/only/bdd.spec.jsrename to test/misc/only/bdd.spec.jsdiff --git a/test/acceptance/misc/only/global/bdd.spec.js b/test/misc/only/global/bdd.spec.jssimilarity index 100%rename from test/acceptance/misc/only/global/bdd.spec.jsrename to test/misc/only/global/bdd.spec.jsdiff --git a/test/acceptance/misc/only/global/qunit.spec.js b/test/misc/only/global/qunit.spec.jssimilarity index 100%rename from test/acceptance/misc/only/global/qunit.spec.jsrename to test/misc/only/global/qunit.spec.jsdiff --git a/test/acceptance/misc/only/global/tdd.spec.js b/test/misc/only/global/tdd.spec.jssimilarity index 100%rename from test/acceptance/misc/only/global/tdd.spec.jsrename to test/misc/only/global/tdd.spec.jsdiff --git a/test/acceptance/misc/only/qunit.spec.js b/test/misc/only/qunit.spec.jssimilarity index 100%rename from test/acceptance/misc/only/qunit.spec.jsrename to test/misc/only/qunit.spec.jsdiff --git a/test/acceptance/misc/only/tdd.spec.js b/test/misc/only/tdd.spec.jssimilarity index 100%rename from test/acceptance/misc/only/tdd.spec.jsrename to test/misc/only/tdd.spec.jsdiff --git a/test/color.spec.js b/test/node-unit/color.spec.jssimilarity index 100%rename from test/color.spec.jsrename to test/node-unit/color.spec.jsdiff --git a/test/acceptance/file-utils.spec.js b/test/node-unit/file-utils.spec.jssimilarity index 100%rename from test/acceptance/file-utils.spec.jsrename to test/node-unit/file-utils.spec.jsdiff --git a/test/acceptance/fs.spec.js b/test/node-unit/fs.spec.jssimilarity index 100%rename from test/acceptance/fs.spec.jsrename to test/node-unit/fs.spec.jsdiff --git a/test/http-meta-2.spec.js b/test/node-unit/http-meta-2.spec.jssimilarity index 100%rename from test/http-meta-2.spec.jsrename to test/node-unit/http-meta-2.spec.jsdiff --git a/test/http-meta.spec.js b/test/node-unit/http-meta.spec.jssimilarity index 100%rename from test/http-meta.spec.jsrename to test/node-unit/http-meta.spec.jsdiff --git a/test/acceptance/http.spec.js b/test/node-unit/http.spec.jssimilarity index 100%rename from test/acceptance/http.spec.jsrename to test/node-unit/http.spec.jsdiff --git a/test/node-unit/stack-trace-filter.spec.js b/test/node-unit/stack-trace-filter.spec.jsnew file mode 100644index 00000000..72ce67a2--- /dev/null+++ b/test/node-unit/stack-trace-filter.spec.js@@ -0,0 +1,156 @@+'use strict';++var path = require('path');+var utils = require('../../lib/utils');++describe('stackTraceFilter()', function () {+ describe('on node', function () {+ var filter = utils.stackTraceFilter();++ describe('on POSIX OS', function () {+ before(function () {+ if (path.sep !== '/') {+ this.skip();+ }+ });++ it('should get a stack-trace as a string and prettify it', function () {+ var stack = [+ 'AssertionError: foo bar',+ 'at EventEmitter.<anonymous> (/usr/local/dev/test.js:16:12)',+ 'at Context.<anonymous> (/usr/local/dev/test.js:19:5)',+ 'Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:244:7)',+ 'Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)',+ '/usr/local/lib/node_modules/mocha/lib/runner.js:452:12',+ 'next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)',+ '/usr/local/lib/node_modules/mocha/lib/runner.js:309:7',+ 'next (/usr/local/lib/node_modules/mocha/lib/runner.js:248:23)',+ 'Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)',+ 'at processImmediate [as _immediateCallback] (timers.js:321:17)'+ ];+ filter(stack.join('\n'))+ .should+ .equal(stack.slice(0, 3)+ .join('\n'));++ stack = [+ 'AssertionError: bar baz',+ 'at /usr/local/dev/some-test-file.js:25:8',+ 'at tryCatcher (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/util.js:24:31)',+ 'at Promise._resolveFromResolver (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:439:31)',+ 'at new Promise (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:53:37)',+ 'at yourFunction (/usr/local/dev/own/tmp/test1.js:24:13)',+ 'at Context.<anonymous> (/usr/local/dev/some-test-file:30:4)',+ 'Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:218:15)',+ 'next (/usr/local/lib/node_modules/mocha/lib/runner.js:248:23)',+ 'Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)',+ 'at processImmediate [as _immediateCallback] (timers.js:321:17)'+ ];++ filter(stack.join('\n'))+ .should+ .equal(stack.slice(0, 7)+ .join('\n'));+ });++ it('does not ignore other bower_components and components', function () {+ var stack = [+ 'Error: failed',+ 'at assert (index.html:11:26)',+ 'at Context.<anonymous> (test.js:17:18)',+ 'at bower_components/should/should.js:4827:7',+ 'at next (file:///.../bower_components/should/should.js:4766:23)',+ 'at components/should/5.0.0/should.js:4827:7',+ 'at next (file:///.../components/should/5.0.0/should.js:4766:23)',+ 'at file:///.../bower_components/mocha/mocha.js:4794:5',+ 'at timeslice (.../components/mocha/mocha.js:6218:27)',+ 'at Test.require.register.Runnable.run (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4463:15)',+ 'at Runner.require.register.Runner.runTest (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4892:10)',+ 'at file:///.../components/mochajs/mocha/2.1.0/mocha.js:4970:12',+ 'at next (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4817:14)'+ ];+ filter(stack.join('\n'))+ .should+ .equal(stack.slice(0, 7)+ .join('\n'));+ });++ it('should replace absolute with relative paths', function () {+ var stack = [+ 'Error: ' + process.cwd() + '/bla.js has a problem',+ 'at foo (' + process.cwd() + '/foo/index.js:13:226)',+ 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'+ ];++ var expected = [+ 'Error: ' + process.cwd() + '/bla.js has a problem',+ 'at foo (foo/index.js:13:226)',+ 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'+ ];++ filter(stack.join('\n'))+ .should+ .equal(expected.join('\n'));+ });+ });++ describe('on Windows', function () {+ before(function () {+ if (path.sep === '/') {+ this.skip();+ }+ });++ it('should work on Windows', function () {+ var stack = [+ 'Error: failed',+ 'at Context.<anonymous> (C:\\Users\\ishida\\src\\test\\test\\mytest.js:5:9)',+ 'at callFn (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runnable.js:326:21)',+ 'at Test.Runnable.run (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runnable.js:319:7)',+ 'at Runner.runTest (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:422:10)',+ 'at C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:528:12',+ 'at next (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:342:14)',+ 'at C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:352:7',+ 'at next (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:284:14)',+ 'at Immediate._onImmediate (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:320:5)'+ ];+ filter(stack.join('\n'))+ .should+ .equal(stack.slice(0, 2)+ .join('\n'));+ });+ });+ });++ describe('on browser', function () {+ var filter;+ before(function () {+ global.document = true;+ global.location = {href: 'localhost:3000/foo/bar/index.html'};+ filter = utils.stackTraceFilter();+ });+ it('does not strip out other bower_components', function () {+ var stack = [+ 'Error: failed',+ 'at assert (index.html:11:26)',+ 'at Context.<anonymous> (test.js:17:18)',+ 'at bower_components/should/should.js:4827:7',+ 'at next (bower_components/should/should.js:4766:23)',+ 'at components/should/5.0.0/should.js:4827:7',+ 'at next (components/should/5.0.0/should.js:4766:23)',+ 'at Runner.require.register.Runner.runTest (node_modules/mocha.js:4892:10)',+ 'at localhost:3000/foo/bar/node_modules/mocha.js:4970:12',+ 'at next (node_modules/mocha.js:4817:14)'+ ];+ filter(stack.join('\n'))+ .should+ .equal(stack.slice(0, 7)+ .join('\n'));+ });++ after(function () {+ delete global.document;+ delete global.location;+ });+ });+});diff --git a/test/acceptance/require/a.js b/test/require/a.jssimilarity index 100%rename from test/acceptance/require/a.jsrename to test/require/a.jsdiff --git a/test/acceptance/require/b.coffee b/test/require/b.coffeesimilarity index 100%rename from test/acceptance/require/b.coffeerename to test/require/b.coffeediff --git a/test/acceptance/require/c.js b/test/require/c.jssimilarity index 100%rename from test/acceptance/require/c.jsrename to test/require/c.jsdiff --git a/test/acceptance/require/d.coffee b/test/require/d.coffeesimilarity index 100%rename from test/acceptance/require/d.coffeerename to test/require/d.coffeediff --git a/test/acceptance/require/require.spec.js b/test/require/require.spec.jssimilarity index 100%rename from test/acceptance/require/require.spec.jsrename to test/require/require.spec.jsdiff --git a/test/acceptance/context.spec.js b/test/unit/context.spec.jssimilarity index 100%rename from test/acceptance/context.spec.jsrename to test/unit/context.spec.jsdiff --git a/test/acceptance/duration.spec.js b/test/unit/duration.spec.jssimilarity index 100%rename from test/acceptance/duration.spec.jsrename to test/unit/duration.spec.jsdiff --git a/test/acceptance/globals.spec.js b/test/unit/globals.spec.jssimilarity index 100%rename from test/acceptance/globals.spec.jsrename to test/unit/globals.spec.jsdiff --git a/test/grep.spec.js b/test/unit/grep.spec.jssimilarity index 98%rename from test/grep.spec.jsrename to test/unit/grep.spec.jsindex dd21cf00..bb620f9b 100644--- a/test/grep.spec.js+++ b/test/unit/grep.spec.js@@ -1,6 +1,6 @@'use strict';-var Mocha = require('../');+var Mocha = require('../../lib/mocha');describe('Mocha', function () {describe('"grep" option', function () {diff --git a/test/hook-async.spec.js b/test/unit/hook-async.spec.jssimilarity index 100%rename from test/hook-async.spec.jsrename to test/unit/hook-async.spec.jsdiff --git a/test/hook-sync-nested.spec.js b/test/unit/hook-sync-nested.spec.jssimilarity index 100%rename from test/hook-sync-nested.spec.jsrename to test/unit/hook-sync-nested.spec.jsdiff --git a/test/hook-sync.spec.js b/test/unit/hook-sync.spec.jssimilarity index 100%rename from test/hook-sync.spec.jsrename to test/unit/hook-sync.spec.jsdiff --git a/test/hook-timeout.spec.js b/test/unit/hook-timeout.spec.jssimilarity index 100%rename from test/hook-timeout.spec.jsrename to test/unit/hook-timeout.spec.jsdiff --git a/test/mocha.spec.js b/test/unit/mocha.spec.jssimilarity index 95%rename from test/mocha.spec.jsrename to test/unit/mocha.spec.jsindex 618742cd..af0c44a7 100644--- a/test/mocha.spec.js+++ b/test/unit/mocha.spec.js@@ -1,6 +1,6 @@'use strict';-var Mocha = require('../');+var Mocha = require('../../lib/mocha');var Test = Mocha.Test;describe('Mocha', function () {diff --git a/test/ms.spec.js b/test/unit/ms.spec.jssimilarity index 98%rename from test/ms.spec.jsrename to test/unit/ms.spec.jsindex 26f5c302..6ceab5d4 100644--- a/test/ms.spec.js+++ b/test/unit/ms.spec.js@@ -1,5 +1,5 @@'use strict';-var ms = require('../lib/ms');+var ms = require('../../lib/ms');describe('.ms()', function () {// Helpersdiff --git a/test/acceptance/overspecified-async.spec.js b/test/unit/overspecified-async.spec.jssimilarity index 100%rename from test/acceptance/overspecified-async.spec.jsrename to test/unit/overspecified-async.spec.jsdiff --git a/test/acceptance/required-tokens.spec.js b/test/unit/required-tokens.spec.jssimilarity index 100%rename from test/acceptance/required-tokens.spec.jsrename to test/unit/required-tokens.spec.jsdiff --git a/test/acceptance/root.spec.js b/test/unit/root.spec.jssimilarity index 100%rename from test/acceptance/root.spec.jsrename to test/unit/root.spec.jsdiff --git a/test/runnable.spec.js b/test/unit/runnable.spec.jssimilarity index 96%rename from test/runnable.spec.jsrename to test/unit/runnable.spec.jsindex 67cfcca3..59bffff7 100644--- a/test/runnable.spec.js+++ b/test/unit/runnable.spec.js@@ -1,6 +1,6 @@'use strict';-var mocha = require('../');+var mocha = require('../../lib/mocha');var utils = mocha.utils;var Runnable = mocha.Runnable;@@ -183,7 +183,9 @@ describe('Runnable(title, fn)', function () {describe('when timeouts are disabled', function () {it('should not error with timeout', function (done) {var test = new Runnable('foo', function (done) {- setTimeout(process.nextTick.bind(undefined, done), 2);+ setTimeout(function () {+ setTimeout(done);+ }, 2);});test.timeout(1);test.enableTimeouts(false);@@ -195,7 +197,7 @@ describe('Runnable(title, fn)', function () {describe('without error', function () {it('should invoke the callback', function (done) {var test = new Runnable('foo', function (done) {- process.nextTick(done);+ setTimeout(done);});test.run(done);@@ -210,9 +212,9 @@ describe('Runnable(title, fn)', function () {var test = new Runnable('foo', function (done) {process.nextTick(done);- process.nextTick(done);- process.nextTick(done);- process.nextTick(done);+ setTimeout(done);+ setTimeout(done);+ setTimeout(done);});test.on('error', function (err) {@@ -236,10 +238,10 @@ describe('Runnable(title, fn)', function () {var test = new Runnable('foo', function (done) {done(new Error('fail'));- process.nextTick(done);+ setTimeout(done);done(new Error('fail'));- process.nextTick(done);- process.nextTick(done);+ setTimeout(done);+ setTimeout(done);});test.on('error', function (err) {@@ -359,7 +361,7 @@ describe('Runnable(title, fn)', function () {describe('when the promise is fulfilled with no value', function () {var fulfilledPromise = {then: function (fulfilled, rejected) {- process.nextTick(fulfilled);+ setTimeout(fulfilled);}};@@ -375,7 +377,7 @@ describe('Runnable(title, fn)', function () {describe('when the promise is fulfilled with a value', function () {var fulfilledPromise = {then: function (fulfilled, rejected) {- process.nextTick(function () {+ setTimeout(function () {fulfilled({});});}@@ -394,7 +396,7 @@ describe('Runnable(title, fn)', function () {var expectedErr = new Error('fail');var rejectedPromise = {then: function (fulfilled, rejected) {- process.nextTick(function () {+ setTimeout(function () {rejected(expectedErr);});}@@ -416,7 +418,7 @@ describe('Runnable(title, fn)', function () {var expectedErr = new Error('Promise rejected with no or falsy reason');var rejectedPromise = {then: function (fulfilled, rejected) {- process.nextTick(function () {+ setTimeout(function () {rejected();});}diff --git a/test/runner.spec.js b/test/unit/runner.spec.jssimilarity index 99%rename from test/runner.spec.jsrename to test/unit/runner.spec.jsindex 7c69846e..c3dc379d 100644--- a/test/runner.spec.js+++ b/test/unit/runner.spec.js@@ -1,6 +1,6 @@'use strict';-var mocha = require('../');+var mocha = require('../../lib/mocha');var Suite = mocha.Suite;var Runner = mocha.Runner;var Test = mocha.Test;diff --git a/test/suite.spec.js b/test/unit/suite.spec.jssimilarity index 99%rename from test/suite.spec.jsrename to test/unit/suite.spec.jsindex 4cb62dd2..4233f957 100644--- a/test/suite.spec.js+++ b/test/unit/suite.spec.js@@ -1,6 +1,6 @@'use strict';-var mocha = require('../');+var mocha = require('../../lib/mocha');var Suite = mocha.Suite;var Test = mocha.Test;diff --git a/test/test.spec.js b/test/unit/test.spec.jssimilarity index 98%rename from test/test.spec.jsrename to test/unit/test.spec.jsindex 73c09b3b..455cfe04 100644--- a/test/test.spec.js+++ b/test/unit/test.spec.js@@ -1,6 +1,6 @@'use strict';-var mocha = require('../');+var mocha = require('../../lib/mocha');var should = require('should');var Test = mocha.Test;diff --git a/test/acceptance/throw.spec.js b/test/unit/throw.spec.jssimilarity index 100%rename from test/acceptance/throw.spec.jsrename to test/unit/throw.spec.jsdiff --git a/test/acceptance/timeout.spec.js b/test/unit/timeout.spec.jssimilarity index 100%rename from test/acceptance/timeout.spec.jsrename to test/unit/timeout.spec.jsdiff --git a/test/acceptance/utils.spec.js b/test/unit/utils.spec.jssimilarity index 71%rename from test/acceptance/utils.spec.jsrename to test/unit/utils.spec.jsindex 545bdfd2..85b19507 100644--- a/test/acceptance/utils.spec.js+++ b/test/unit/utils.spec.js@@ -6,13 +6,80 @@ var JSON = require('json3');describe('lib/utils', function () {describe('clean', function () {+ it('should remove the wrapping function declaration', function () {+ utils.clean('function (one, two, three) {\n//code\n}')+ .should+ .equal('//code');+ });++ it('should handle newlines in the function declaration', function () {+ utils.clean('function (one, two, three)\n {\n//code\n}')+ .should+ .equal('//code');+ });++ it('should remove space character indentation from the function body',+ function () {+ utils.clean(' //line1\n //line2')+ .should+ .equal('//line1\n //line2');+ });++ it('should remove tab character indentation from the function body',+ function () {+ utils.clean('\t//line1\n\t\t//line2')+ .should+ .equal('//line1\n\t//line2');+ });++ it('should handle functions with tabs in their declarations', function () {+ utils.clean('function\t(\t)\t{\n//code\n}')+ .should+ .equal('//code');+ });++ it('should handle named functions without space after name', function () {+ utils.clean('function withName() {\n//code\n}')+ .should+ .equal('//code');+ });++ it('should handle named functions with space after name', function () {+ utils.clean('function withName () {\n//code\n}')+ .should+ .equal('//code');+ });++ it(+ 'should handle functions with no space between the end and the closing brace',+ function () {+ utils.clean('function() {/*code*/}')+ .should+ .equal('/*code*/');+ });++ it('should handle functions with parentheses in the same line',+ function () {+ utils.clean('function() { if (true) { /* code */ } }')+ .should+ .equal('if (true) { /* code */ }');+ });++ it('should handle empty functions', function () {+ utils.clean('function() {}')+ .should+ .equal('');+ });+it('should format a single line test function', function () {var fn = ['function () {',' var a = 1;','}'].join('\n');- expect(utils.clean(fn)).to.equal('var a = 1;');+ expect(utils.clean(fn))+ .to+ .equal('var a = 1;');});it('should format a multi line test indented with spaces', function () {@@ -23,7 +90,9 @@ describe('lib/utils', function () {' var b = 2;',' var c = 3; }'].join('\n');- expect(utils.clean(fn)).to.equal('var a = 1;\n var b = 2;\nvar c = 3;');+ expect(utils.clean(fn))+ .to+ .equal('var a = 1;\n var b = 2;\nvar c = 3;');});it('should format a multi line test indented with tabs', function () {@@ -34,7 +103,9 @@ describe('lib/utils', function () {'\t}','}'].join('\n');- expect(utils.clean(fn)).to.equal('if (true) {\n\tvar a = 1;\n}');+ expect(utils.clean(fn))+ .to+ .equal('if (true) {\n\tvar a = 1;\n}');});it('should format functions saved in windows style - spaces', function () {@@ -45,7 +116,9 @@ describe('lib/utils', function () {' } while (false);',' }'].join('\r\n');- expect(utils.clean(fn)).to.equal('do {\n "nothing";\n} while (false);');+ expect(utils.clean(fn))+ .to+ .equal('do {\n "nothing";\n} while (false);');});it('should format functions saved in windows style - tabs', function () {@@ -58,7 +131,9 @@ describe('lib/utils', function () {'\t}','}'].join('\r\n');- expect(utils.clean(fn)).to.equal('if (false) {\n\tvar json = {\n\t\tone : 1\n\t};\n}');+ expect(utils.clean(fn))+ .to+ .equal('if (false) {\n\tvar json = {\n\t\tone : 1\n\t};\n}');});it('should format es6 arrow functions', function () {@@ -67,12 +142,16 @@ describe('lib/utils', function () {' var a = 1;','}'].join('\n');- expect(utils.clean(fn)).to.equal('var a = 1;');+ expect(utils.clean(fn))+ .to+ .equal('var a = 1;');});it('should format es6 arrow functions with implicit return', function () {var fn = '() => foo()';- expect(utils.clean(fn)).to.equal('foo()');+ expect(utils.clean(fn))+ .to+ .equal('foo()');});});@@ -415,4 +494,129 @@ describe('lib/utils', function () {Object.prototype.toString = toString;});});++ describe('isBuffer()', function () {+ var isBuffer = utils.isBuffer;+ it('should test if object is a Buffer', function () {+ isBuffer(new Buffer([0x01]))+ .should+ .equal(true);+ isBuffer({})+ .should+ .equal(false);+ });+ });++ describe('map()', function () {+ var map = utils.map;+ it('should behave same as Array.prototype.map', function () {+ var arr = [+ 1,+ 2,+ 3+ ];+ map(arr, JSON.stringify)+ .should+ .eql(arr.map(JSON.stringify));+ });++ it('should call the callback with 3 arguments[currentValue, index, array]',+ function () {+ var index = 0;+ map([+ 1,+ 2,+ 3+ ], function (e, i, arr) {+ e.should.equal(arr[index]);+ i.should.equal(index++);+ });+ });++ it('should apply with the given scope', function () {+ var scope = {};+ map([+ 'a',+ 'b',+ 'c'+ ], function () {+ this.should.equal(scope);+ }, scope);+ });+ });++ describe('some()', function () {+ var some = utils.some;++ it(+ 'should return true when some array elements pass the check of the fn parameter',+ function () {+ var result = some([+ 'a',+ 'b',+ 'c'+ ], function (e) {+ return e === 'b';+ });+ result.should.eql(true);+ });++ it(+ 'should return false when none of the array elements pass the check of the fn parameter',+ function () {+ var result = some([+ 'a',+ 'b',+ 'c'+ ], function (e) {+ return e === 'd';+ });+ result.should.eql(false);+ });+ });++ describe('parseQuery()', function () {+ var parseQuery = utils.parseQuery;+ it('should get queryString and return key-value object', function () {+ parseQuery('?foo=1&bar=2&baz=3')+ .should+ .eql({+ foo: '1',+ bar: '2',+ baz: '3'+ });++ parseQuery('?r1=^@(?!.*\\)$)&r2=m{2}&r3=^co.*')+ .should+ .eql({+ r1: '^@(?!.*\\)$)',+ r2: 'm{2}',+ r3: '^co.*'+ });+ });++ it('should parse "+" as a space', function () {+ parseQuery('?grep=foo+bar')+ .should+ .eql({grep: 'foo bar'});+ });+ });++ describe('isPromise', function () {+ it('should return true if the value is Promise-ish', function () {+ utils.isPromise({+ then: function () {+ }+ }).should.be.true;+ });++ it('should return false if the value is not an object', function () {+ utils.isPromise(1).should.be.false;+ });++ it('should return false if the value is an object w/o a "then" function',+ function () {+ utils.isPromise({}).should.be.false;+ });+ });});diff --git a/test/utils.spec.js b/test/utils.spec.jsdeleted file mode 100644index 2eaf908c..00000000--- a/test/utils.spec.js+++ /dev/null@@ -1,285 +0,0 @@-'use strict';--var mocha = require('..');-var utils = mocha.utils;-var path = require('path');-var JSON = require('json3');--describe('utils', function () {- describe('.clean()', function () {- var clean = utils.clean;- it('should remove the wrapping function declaration', function () {- clean('function (one, two, three) {\n//code\n}').should.equal('//code');- });-- it('should handle newlines in the function declaration', function () {- clean('function (one, two, three)\n {\n//code\n}').should.equal('//code');- });-- it('should remove space character indentation from the function body', function () {- clean(' //line1\n //line2').should.equal('//line1\n //line2');- });-- it('should remove tab character indentation from the function body', function () {- clean('\t//line1\n\t\t//line2').should.equal('//line1\n\t//line2');- });-- it('should handle functions with tabs in their declarations', function () {- clean('function\t(\t)\t{\n//code\n}').should.equal('//code');- });-- it('should handle named functions without space after name', function () {- clean('function withName() {\n//code\n}').should.equal('//code');- });-- it('should handle named functions with space after name', function () {- clean('function withName () {\n//code\n}').should.equal('//code');- });-- it('should handle functions with no space between the end and the closing brace', function () {- clean('function() {/*code*/}').should.equal('/*code*/');- });-- it('should handle functions with parentheses in the same line', function () {- clean('function() { if (true) { /* code */ } }').should.equal('if (true) { /* code */ }');- });-- it('should handle empty functions', function () {- clean('function() {}').should.equal('');- });- });-- describe('.isBuffer()', function () {- var isBuffer = utils.isBuffer;- it('should test if object is a Buffer', function () {- isBuffer(new Buffer([0x01])).should.equal(true);- isBuffer({}).should.equal(false);- });- });-- describe('.map()', function () {- var map = utils.map;- it('should behave same as Array.prototype.map', function () {- var arr = [1, 2, 3];- map(arr, JSON.stringify).should.eql(arr.map(JSON.stringify));- });-- it('should call the callback with 3 arguments[currentValue, index, array]', function () {- var index = 0;- map([1, 2, 3], function (e, i, arr) {- e.should.equal(arr[index]);- i.should.equal(index++);- });- });-- it('should apply with the given scope', function () {- var scope = {};- map(['a', 'b', 'c'], function () {- this.should.equal(scope);- }, scope);- });- });-- describe('.some()', function () {- var some = utils.some;-- it('should return true when some array elements pass the check of the fn parameter', function () {- var result = some(['a', 'b', 'c'], function (e) {- return e === 'b';- });- result.should.eql(true);- });-- it('should return false when none of the array elements pass the check of the fn parameter', function () {- var result = some(['a', 'b', 'c'], function (e) {- return e === 'd';- });- result.should.eql(false);- });- });-- describe('.parseQuery()', function () {- var parseQuery = utils.parseQuery;- it('should get queryString and return key-value object', function () {- parseQuery('?foo=1&bar=2&baz=3').should.eql({- foo: '1',- bar: '2',- baz: '3'- });-- parseQuery('?r1=^@(?!.*\\)$)&r2=m{2}&r3=^co.*').should.eql({- r1: '^@(?!.*\\)$)',- r2: 'm{2}',- r3: '^co.*'- });- });-- it('should parse "+" as a space', function () {- parseQuery('?grep=foo+bar').should.eql({grep: 'foo bar'});- });- });-- describe('.stackTraceFilter()', function () {- describe('on node', function () {- var filter = utils.stackTraceFilter();-- describe('on POSIX OS', function () {- before(function () {- if (path.sep !== '/') {- this.skip();- }- });-- it('should get a stack-trace as a string and prettify it', function () {- var stack = [- 'AssertionError: foo bar',- 'at EventEmitter.<anonymous> (/usr/local/dev/test.js:16:12)',- 'at Context.<anonymous> (/usr/local/dev/test.js:19:5)',- 'Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:244:7)',- 'Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)',- '/usr/local/lib/node_modules/mocha/lib/runner.js:452:12',- 'next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)',- '/usr/local/lib/node_modules/mocha/lib/runner.js:309:7',- 'next (/usr/local/lib/node_modules/mocha/lib/runner.js:248:23)',- 'Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)',- 'at processImmediate [as _immediateCallback] (timers.js:321:17)'- ];- filter(stack.join('\n'))- .should- .equal(stack.slice(0, 3)- .join('\n'));-- stack = [- 'AssertionError: bar baz',- 'at /usr/local/dev/some-test-file.js:25:8',- 'at tryCatcher (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/util.js:24:31)',- 'at Promise._resolveFromResolver (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:439:31)',- 'at new Promise (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:53:37)',- 'at yourFunction (/usr/local/dev/own/tmp/test1.js:24:13)',- 'at Context.<anonymous> (/usr/local/dev/some-test-file:30:4)',- 'Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:218:15)',- 'next (/usr/local/lib/node_modules/mocha/lib/runner.js:248:23)',- 'Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)',- 'at processImmediate [as _immediateCallback] (timers.js:321:17)'- ];-- filter(stack.join('\n'))- .should- .equal(stack.slice(0, 7)- .join('\n'));- });-- it('does not ignore other bower_components and components',- function () {- var stack = [- 'Error: failed',- 'at assert (index.html:11:26)',- 'at Context.<anonymous> (test.js:17:18)',- 'at bower_components/should/should.js:4827:7',- 'at next (file:///.../bower_components/should/should.js:4766:23)',- 'at components/should/5.0.0/should.js:4827:7',- 'at next (file:///.../components/should/5.0.0/should.js:4766:23)',- 'at file:///.../bower_components/mocha/mocha.js:4794:5',- 'at timeslice (.../components/mocha/mocha.js:6218:27)',- 'at Test.require.register.Runnable.run (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4463:15)',- 'at Runner.require.register.Runner.runTest (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4892:10)',- 'at file:///.../components/mochajs/mocha/2.1.0/mocha.js:4970:12',- 'at next (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4817:14)'- ];- filter(stack.join('\n'))- .should- .equal(stack.slice(0, 7)- .join('\n'));- });-- it('should replace absolute with relative paths', function () {- var stack = [- 'Error: ' + process.cwd() + '/bla.js has a problem',- 'at foo (' + process.cwd() + '/foo/index.js:13:226)',- 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'- ];-- var expected = [- 'Error: ' + process.cwd() + '/bla.js has a problem',- 'at foo (foo/index.js:13:226)',- 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'- ];-- filter(stack.join('\n'))- .should- .equal(expected.join('\n'));- });- });-- describe('on Windows', function () {- before(function () {- if (path.sep === '/') {- this.skip();- }- });-- it('should work on Windows', function () {- var stack = [- 'Error: failed',- 'at Context.<anonymous> (C:\\Users\\ishida\\src\\test\\test\\mytest.js:5:9)',- 'at callFn (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runnable.js:326:21)',- 'at Test.Runnable.run (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runnable.js:319:7)',- 'at Runner.runTest (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:422:10)',- 'at C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:528:12',- 'at next (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:342:14)',- 'at C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:352:7',- 'at next (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:284:14)',- 'at Immediate._onImmediate (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:320:5)'- ];- filter(stack.join('\n'))- .should- .equal(stack.slice(0, 2)- .join('\n'));- });- });- });-- describe('on browser', function () {- var filter;- before(function () {- global.document = true;- global.location = { href: 'localhost:3000/foo/bar/index.html' };- filter = utils.stackTraceFilter();- });- it('does not strip out other bower_components', function () {- var stack = [- 'Error: failed',- 'at assert (index.html:11:26)',- 'at Context.<anonymous> (test.js:17:18)',- 'at bower_components/should/should.js:4827:7',- 'at next (bower_components/should/should.js:4766:23)',- 'at components/should/5.0.0/should.js:4827:7',- 'at next (components/should/5.0.0/should.js:4766:23)',- 'at Runner.require.register.Runner.runTest (node_modules/mocha.js:4892:10)',- 'at localhost:3000/foo/bar/node_modules/mocha.js:4970:12',- 'at next (node_modules/mocha.js:4817:14)'- ];- filter(stack.join('\n')).should.equal(stack.slice(0, 7).join('\n'));- });-- after(function () {- delete global.document;- delete global.location;- });- });- });-- describe('.isPromise', function () {- it('should return true if the value is Promise-ish', function () {- utils.isPromise({then: function () {}}).should.be.true;- });-- it('should return false if the value is not an object', function () {- utils.isPromise(1).should.be.false;- });-- it('should return false if the value is an object w/o a "then" function', function () {- utils.isPromise({}).should.be.false;- });- });-});