diff options
Diffstat (limited to 'tests/lib')
298 files changed, 4327 insertions, 3890 deletions
diff --git a/tests/lib/mocha-3.1.0/.eslintignore b/tests/lib/mocha-3.1.0/.eslintignore deleted file mode 100644 index 2b550ca81d..0000000000 --- a/tests/lib/mocha-3.1.0/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -lib/to-iso-string/ -test/**/* -!test/runner.js diff --git a/tests/lib/mocha-3.1.0/.eslintrc b/tests/lib/mocha-3.1.0/.eslintrc deleted file mode 100644 index d5c733f79f..0000000000 --- a/tests/lib/mocha-3.1.0/.eslintrc +++ /dev/null @@ -1,129 +0,0 @@ ---- -env: - node: true - -rules: - brace-style: [2, 1tbs] - camelcase: 2 - comma-dangle: [2, never] - comma-spacing: [2, {before: false, after: true}] - comma-style: [2, last] - computed-property-spacing: [2, never] - consistent-return: 0 - consistent-this: [1, self] - curly: [2, all] - default-case: 2 - dot-location: [2, property] - dot-notation: [2, { allowKeywords: true, allowPattern: "^long$" }] - eol-last: 2 - eqeqeq: 2 - func-style: [2, declaration] - guard-for-in: 2 # TODO: Change to error - handle-callback-err: [2, ^(err|error)$] - indent: [2, 2, { SwitchCase: 1 }] - key-spacing: [2, { beforeColon: false, afterColon: true }] - max-len: [0, 80, 2] # TODO: Change to error - max-params: [1, 4] - new-cap: 0 # TODO: Change to error - new-parens: 2 - no-alert: 2 - no-array-constructor: 0 - no-bitwise: 0 - no-caller: 2 - no-catch-shadow: 2 - no-cond-assign: [1, except-parens] # TODO: Change to error - no-console: 0 - no-constant-condition: 0 - no-control-regex: 2 - no-debugger: 1 - no-delete-var: 2 - no-dupe-args: 2 - no-dupe-keys: 2 - no-duplicate-case: 2 - no-else-return: 2 - no-empty: 2 - no-empty-character-class: 2 - no-eq-null: 0 - no-eval: 2 - no-ex-assign: 2 - no-extend-native: 2 - no-extra-bind: 2 - no-extra-boolean-cast: 2 - no-extra-semi: 2 - no-fallthrough: 2 - no-floating-decimal: 0 - no-func-assign: 2 - no-implied-eval: 2 - no-inner-declarations: [2, functions] - no-invalid-regexp: 2 - no-irregular-whitespace: 2 - no-iterator: 2 - no-labels: 2 - no-lone-blocks: 2 - no-lonely-if: 2 - no-loop-func: 2 - no-mixed-requires: [0, false] - no-mixed-spaces-and-tabs: [2, false] - no-multi-spaces: 2 - no-multi-str: 2 - no-multiple-empty-lines: [2, { max: 1 }] - no-native-reassign: 2 - no-negated-in-lhs: 2 - no-nested-ternary: 2 - no-new: 2 - no-new-func: 2 - no-new-object: 2 - no-new-require: 2 - no-new-wrappers: 2 - no-obj-calls: 2 - no-octal: 2 - no-octal-escape: 2 - no-path-concat: 2 - no-process-exit: 2 - no-proto: 1 # TODO: Change to error - no-redeclare: 2 - no-regex-spaces: 2 - no-return-assign: 2 - no-script-url: 2 - no-self-compare: 2 - no-sequences: 2 - no-shadow: 0 - no-shadow-restricted-names: 2 - no-spaced-func: 2 - no-sparse-arrays: 2 - no-trailing-spaces: 2 - no-undef: 2 - no-undef-init: 2 - no-underscore-dangle: 0 # TODO: Change to error - no-unneeded-ternary: 2 - no-unreachable: 2 - no-unused-expressions: 0 - no-unused-vars: [2, { vars: all, args: after-used }] - no-use-before-define: 0 - no-void: 2 - no-with: 2 - object-curly-spacing: [2, always] - one-var: [2, never] - operator-assignment: [2, always] - operator-linebreak: [2, before] - padded-blocks: [2, never] - quote-props: [2, as-needed] - quotes: [2, single, avoid-escape] - radix: 2 - semi: [2, always] - semi-spacing: [2, { before: false, after: true }] - space-before-blocks: [2, always] - space-before-function-paren: [2, never] - space-in-parens: [2, never] - space-infix-ops: 2 - keyword-spacing: 2 - space-unary-ops: [2, { words: true, nonwords: false }] - spaced-comment: [2, always, { exceptions: ['!'] }] - strict: [0, global] # TODO: Change to error - use-isnan: 2 - valid-jsdoc: [0, { requireReturn: false }] # TODO: Change to warning - valid-typeof: 2 - vars-on-top: 0 - wrap-iife: 2 - wrap-regex: 2 - yoda: [2, never] diff --git a/tests/lib/mocha-3.1.0/lib/browser/debug.js b/tests/lib/mocha-3.1.0/lib/browser/debug.js deleted file mode 100644 index ba232896df..0000000000 --- a/tests/lib/mocha-3.1.0/lib/browser/debug.js +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-unused-vars */ -module.exports = function(type) { - return function() {}; -}; diff --git a/tests/lib/mocha-3.1.0/test/.eslintrc b/tests/lib/mocha-3.1.0/test/.eslintrc deleted file mode 100644 index 956287d60c..0000000000 --- a/tests/lib/mocha-3.1.0/test/.eslintrc +++ /dev/null @@ -1,5 +0,0 @@ ---- -env: - mocha: true -globals: - expect: false diff --git a/tests/lib/mocha-3.1.0/test/acceptance/duration.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/duration.spec.js deleted file mode 100644 index 4f319b8a3c..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/duration.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -describe('durations', function(){ - describe('when slow', function(){ - it('should highlight in red', function(done){ - setTimeout(function(){ - done(); - }, 100); - }) - }) - - describe('when reasonable', function(){ - it('should highlight in yellow', function(done){ - setTimeout(function(){ - done(); - }, 50); - }) - }) - - describe('when fast', function(){ - it('should highlight in green', function(done){ - setTimeout(function(){ - done(); - }, 10); - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/acceptance/fs.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/fs.spec.js deleted file mode 100644 index 3a70f2752c..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/fs.spec.js +++ /dev/null @@ -1,20 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var os = require('os'); -var tmpFile = path.join.bind(path, os.tmpdir()); - -describe('fs.readFile()', function(){ - describe('when the file exists', function(){ - it('should succeed', function(done){ - fs.writeFile(tmpFile('mocha'), 'wahoo', done) - }) - }) - - describe('when the file does not exist', function(){ - it('should fail', function(done){ - // uncomment - // fs.readFile(tmpFile('does-not-exist'), done); - done(); - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/acceptance/glob/glob.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/glob/glob.spec.js deleted file mode 100644 index 3029ae82ee..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/glob/glob.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -describe('globbing test', function(){ - it('should find this test', function(){ - // see glob.sh for details - }) -}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/http.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/http.spec.js deleted file mode 100644 index 43b8588508..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/http.spec.js +++ /dev/null @@ -1,16 +0,0 @@ -var http = require('http'); - -var server = http.createServer(function(req, res){ - res.end('Hello World\n'); -}) - -server.listen(8888); - -describe('http', function(){ - it('should provide an example', function(done){ - http.get({ path: '/', port: 8888 }, function(res){ - expect(res).to.have.property('statusCode', 200); - done(); - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/bdd.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/interfaces/bdd.spec.js deleted file mode 100644 index ba444c8f7f..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/bdd.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -describe('integer primitives', function(){ - describe('arithmetic', function(){ - it('should add', function(){ - expect(1 + 1).to.equal(2); - expect(2 + 2).to.equal(4); - }) - - it('should subtract', function(){ - expect(1 - 1).to.equal(0); - expect(2 - 1).to.equal(1); - }) - }) -}) - -describe('integer primitives', function(){ - describe('arithmetic is not', function(){ - it('should add', function(){ - expect(1 + 1).not.to.equal(3); - expect(2 + 2).not.to.equal(5); - }) - }) -}) - -context('test suite', function(){ - beforeEach(function(){ - this.number = 5; - }) - - specify('share a property', function(){ - expect(this.number).to.equal(5); - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/exports.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/interfaces/exports.spec.js deleted file mode 100644 index 08db71200b..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/exports.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -var calls = []; - -exports.Array = { - before: function(){ - calls.push('before'); - }, - - after: function(){ - calls.push('after'); - expect(calls).to.eql([ - 'before' - , 'before each' - , 'one' - , 'after each' - , 'before each' - , 'two' - , 'after each' - , 'after']); - }, - - '#indexOf()': { - beforeEach: function(){ - calls.push('before each'); - }, - - afterEach: function(){ - calls.push('after each'); - }, - - 'should return -1 when the value is not present': function(){ - calls.push('one'); - expect([1,2,3].indexOf(5)).to.equal(-1); - expect([1,2,3].indexOf(0)).to.equal(-1); - }, - - 'should return the correct index when the value is present': function(){ - calls.push('two'); - expect([1,2,3].indexOf(1)).to.equal(0); - expect([1,2,3].indexOf(2)).to.equal(1); - expect([1,2,3].indexOf(3)).to.equal(2); - } - } -}; diff --git a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/qunit.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/interfaces/qunit.spec.js deleted file mode 100644 index d452e769c5..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/qunit.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -function ok(expr, msg) { - if (!expr) throw new Error(msg); -} - -suite('integer primitives'); - -test('should add', function(){ - var number = 2 + 2; - ok(number == 4); -}); - -test('should decrement', function(){ - var number = 3; - ok(--number == 2); - ok(--number == 1); - ok(--number == 0); -}); - -suite('String'); - -test('#length', function(){ - ok('foo'.length == 3); -}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/nontty.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/misc/nontty.spec.js deleted file mode 100644 index 2372a660b9..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/nontty.spec.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('tests for non-tty', function(){ - it('should pass', function(){ - - }) - - it('should fail', function(){ - throw new Error('oh noes') - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/tdd.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/misc/only/tdd.spec.js deleted file mode 100644 index 7e37e7a3b3..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/tdd.spec.js +++ /dev/null @@ -1,125 +0,0 @@ -suite('should only run .only test in this tdd suite', function() { - test('should not run this test', function() { - (0).should.equal(1, 'this test should have been skipped'); - }); - test.only('should run this test', function() { - (0).should.equal(0, 'this .only test should run'); - }); - test('should run this test, not (includes the title of the .only test)', function() { - (0).should.equal(1, 'this test should have been skipped'); - }); -}); - -suite('should not run this suite', function() { - test('should not run this test', function() { - (true).should.equal(false); - }); - - test('should not run this test', function() { - (true).should.equal(false); - }); - - test('should not run this test', function() { - (true).should.equal(false); - }); -}); - -suite.only('should run all tests in this tdd suite', function() { - test('should run this test #1', function() { - (true).should.equal(true); - }); - - test('should run this test #2', function() { - (1).should.equal(1); - }); - - test('should run this test #3', function() { - ('foo').should.equal('foo'); - }); -}); - -suite('should run only suites that marked as `only`', function() { - suite.only('should run all this tdd suite', function() { - test('should run this test #1', function() { - (true).should.equal(true); - }); - - test('should run this test #2', function() { - (true).should.equal(true); - }); - }); - - suite('should not run this suite', function() { - test('should not run this test', function() { - (true).should.equal(false); - }); - }); -}); - -// Nested situation -suite('should not run parent tests', function() { - test('should not run this test', function() { - (true).should.equal(false); - }); - suite('and not the child tests too', function() { - test('should not run this test', function() { - (true).should.equal(false); - }); - suite.only('but run all the tests in this suite', function() { - test('should run this test #1', function() { - (true).should.equal(true); - }); - test('should run this test #2', function() { - (true).should.equal(true); - }); - }); - }); -}); - -// mark test as `only` override the suite behavior -suite.only('should run only tests that marked as `only`', function() { - test('should not run this test #1', function() { - (false).should.equal(true); - }); - - test.only('should run this test #2', function() { - (true).should.equal(true); - }); - - test('should not run this test #3', function() { - (false).should.equal(true); - }); - - test.only('should run this test #4', function() { - (true).should.equal(true); - }); -}); - -suite.only('Should run only test cases that mark as only', function() { - test.only('should runt his test', function() { - (true).should.equal(true); - }); - - test('should not run this test', function() { - (false).should.equal(true); - }); - - suite('should not run this suite', function() { - test('should not run this test', function() { - (false).should.equal(true); - }); - }); -}); - -// Root Suite -test.only('#Root-Suite, should run this test-case #1', function() { - (true).should.equal(true); -}); - -test.only('#Root-Suite, should run this test-case #2', function() { - (true).should.equal(true); -}); - -test('#Root-Suite, should not run this test', function() { - (false).should.equal(true); -}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/require/a.js b/tests/lib/mocha-3.1.0/test/acceptance/require/a.js deleted file mode 100644 index 592d827449..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/require/a.js +++ /dev/null @@ -1,2 +0,0 @@ -global.required = (global.required || []) -global.required.push('a.js') diff --git a/tests/lib/mocha-3.1.0/test/acceptance/require/c.js b/tests/lib/mocha-3.1.0/test/acceptance/require/c.js deleted file mode 100644 index 4e681373a1..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/require/c.js +++ /dev/null @@ -1,2 +0,0 @@ -global.required = (global.required || []) -global.required.push('c.js') diff --git a/tests/lib/mocha-3.1.0/test/acceptance/root.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/root.spec.js deleted file mode 100644 index 037e6a328a..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/root.spec.js +++ /dev/null @@ -1,11 +0,0 @@ -var calls = []; - -before(function(){ - calls.push('before'); -}) - -describe('root', function(){ - it('should be a valid suite', function(){ - expect(calls).to.eql(['before']); - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/acceptance/timeout.spec.js b/tests/lib/mocha-3.1.0/test/acceptance/timeout.spec.js deleted file mode 100644 index f61c3ba566..0000000000 --- a/tests/lib/mocha-3.1.0/test/acceptance/timeout.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -describe('timeouts', function(){ - beforeEach(function(done){ - // uncomment - // setTimeout(done, 3000); - done(); - }) - - it('should error on timeout', function(done){ - // uncomment - // setTimeout(done, 3000); - done(); - }) - - it('should allow overriding per-test', function(done){ - this.timeout(1000); - setTimeout(function(){ - done(); - }, 300); - }) - - describe('disabling', function(){ - it('should allow overriding per-test', function(done){ - this.enableTimeouts(false); - this.timeout(1); - setTimeout(done, 2); - }); - - it('should work with timeout(0)', function(done) { - this.timeout(0); - setTimeout(done, 1); - }) - - describe('using beforeEach', function() { - beforeEach(function () { - this.timeout(0); - }) - - it('should work with timeout(0)', function(done) { - setTimeout(done, 1); - }) - }) - - describe('using before', function() { - before(function () { - this.timeout(0); - }) - - it('should work with timeout(0)', function(done) { - setTimeout(done, 1); - }) - }) - - describe('using enableTimeouts(false)', function() { - this.timeout(4); - - it('should suppress timeout(4)', function(done) { - // The test is in the before() call. - this.enableTimeouts(false); - setTimeout(done, 50); - }) - }) - - describe('suite-level', function() { - this.timeout(0); - - it('should work with timeout(0)', function(done) { - setTimeout(done, 1); - }) - - describe('nested suite', function () { - it('should work with timeout(0)', function(done) { - setTimeout(done, 1); - }) - - }) - }) - }); - -}) diff --git a/tests/lib/mocha-3.1.0/test/browser/array.spec.js b/tests/lib/mocha-3.1.0/test/browser/array.spec.js deleted file mode 100644 index 26404f6a90..0000000000 --- a/tests/lib/mocha-3.1.0/test/browser/array.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -describe('Array', function(){ - describe('#push()', function(){ - it('should append a value', function(){ - foo = 'asdf' - var arr = []; - arr.push('foo'); - arr.push('bar'); - arr.push('baz'); - assert('foo' == arr[0]); // to test indentation - assert('bar' == arr[1]); - assert('baz' == arr[2]); - }) - - it('should return the length', function(){ - var arr = []; - assert(1 == arr.push('foo')); - assert(2 == arr.push('bar')); - assert(3 == arr.push('baz')); - }) - }) -}) - -describe('Array', function(){ - describe('#pop()', function(){ - it('should remove and return the last value', function(){ - var arr = [1,2,3]; - assert(arr.pop() == 3); - assert(arr.pop() == 2); - assert(arr.pop() == -1); - }) - - it('should adjust .length', function(){ - var arr = [1,2,3]; - arr.pop(); - assert(arr.length == 2); - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/browser/grep.spec.js b/tests/lib/mocha-3.1.0/test/browser/grep.spec.js deleted file mode 100644 index 9531b87aa9..0000000000 --- a/tests/lib/mocha-3.1.0/test/browser/grep.spec.js +++ /dev/null @@ -1,108 +0,0 @@ -// numbers -describe('21', function() { - it('1', function() { - assert(true); - }); - it('2', function() { - assert(true); - }); -}); -// symbols -describe('@Array', function() { - it('.pop()', function() { - assert(true); - }); - it('.push()', function() { - assert(true); - }); - it('.length', function() { - assert(true); - }); -}); - -describe('@Function', function() { - it('.call()', function() { - assert(true); - }); - it('.apply()', function() { - assert(true); - }); - it('.length', function() { - assert(true); - }); - it('.name', function() { - assert(true); - }); - it('.prototype', function() { - assert(true); - }); -}); - -//url with hashtags -describe('#Services',function() { - describe('#http', function() { - it('.createClient()', function() { - assert(true); - }); - it('.Server()', function() { - assert(true); - }); - }); - describe('#crypto', function() { - it('.randomBytes()', function() { - assert(true); - }); - it('.Hmac()', function() { - assert(true); - }); - }); -}); - -// Uppercase -describe('CONSTANTS', function() { - it('.STATUS_CODES', function() { - assert(true); - }); -}); - -// Dates -describe('Date:', function() { - it('01/02/2015', function() { - assert(true); - }); - it('01/03/2015', function() { - assert(true); - }); - it('01/06/2015', function() { - assert(true); - }); -}); - -// etc.. -describe('booking/summary', function() { - it('should be run last', function() { - assert(true); - }); -}); - -describe('component/booking/summary', function() { - it('should be run second', function() { - assert(true); - }); -}); - -describe('component/booking/intro', function() { - it('should be run first', function() { - assert(true); - }); -}); - -describe('contains numbers', function() { - it('should run if the number 92 matching', function() { - assert(true); - }); - - it('should run if the number 8 matching', function() { - assert(true); - }); -});
\ No newline at end of file diff --git a/tests/lib/mocha-3.1.0/test/browser/opts.spec.js b/tests/lib/mocha-3.1.0/test/browser/opts.spec.js deleted file mode 100644 index dbbc9ff172..0000000000 --- a/tests/lib/mocha-3.1.0/test/browser/opts.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -describe('Options', function() { - it('should set timeout value', function() { - assert(this.test._timeout === 1500); - }); -}) diff --git a/tests/lib/mocha-3.1.0/test/browser/stack-trace.spec.js b/tests/lib/mocha-3.1.0/test/browser/stack-trace.spec.js deleted file mode 100644 index b39944db09..0000000000 --- a/tests/lib/mocha-3.1.0/test/browser/stack-trace.spec.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -describe('Stack trace', function() { - it('should prettify the stack-trace', function() { - var err = new Error(); - // We do this fake stack-trace because we under development, - // and our root isn't `node_modules`, `bower` or `components` - err.stack = ['Error: failed' - , 'at assert (stack-trace.html:11:30)' - , 'at Context.<anonymous> (stack-trace.js:5:5)' - , 'at callFn (http://localhost:63342/node_modules/mocha.js:4546:21)' - , 'at Test.require.register.Runnable.run (http://localhost:63342/node_modules/mocha.js:4539:7)' - , 'at Runner.require.register.Runner.runTest (http://localhost:63342/node_modules/mocha.js:4958:10)' - , 'at http://localhost:63342/bower_components/mocha.js:5041:12' - , 'at next (http://localhost:63342/bower_components/mocha.js:4883:14)' - , 'at http://localhost:63342/bower_components/mocha.js:4893:7' - , 'at next (http://localhost:63342/bower_components/mocha.js:4828:23)' - , 'at http://localhost:63342/bower_components/mocha.js:4860:5'].join('\n'); - assert(false, err); - }); -});
\ No newline at end of file diff --git a/tests/lib/mocha-3.1.0/test/fixture-expect.js b/tests/lib/mocha-3.1.0/test/fixture-expect.js deleted file mode 100644 index cacc78425a..0000000000 --- a/tests/lib/mocha-3.1.0/test/fixture-expect.js +++ /dev/null @@ -1 +0,0 @@ -global.expect = require("expect.js") diff --git a/tests/lib/mocha-3.1.0/test/hook-async.spec.js b/tests/lib/mocha-3.1.0/test/hook-async.spec.js deleted file mode 100644 index ae6e642d24..0000000000 --- a/tests/lib/mocha-3.1.0/test/hook-async.spec.js +++ /dev/null @@ -1,129 +0,0 @@ -describe('async', function(){ - var calls = []; - - before(function(){ - calls.push('root before all'); - }) - - after(function(){ - calls.push('root after all'); - calls.should.eql([ - 'root before all' - , 'before all' - , 'parent before' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test two' - , 'two' - , 'after' - , 'after test two passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test three' - , 'three' - , 'after' - , 'after test three passed' - , 'parent after' - , 'after all' - , 'root after all']); - }) - - beforeEach(function(){ - calls.push('parent before'); - }) - - afterEach(function(){ - calls.push('parent after' ); - }) - - describe('hooks', function(){ - before(function(){ - calls.push('before all'); - }); - - after(function(){ - calls.push('after all'); - }); - - beforeEach(function(done){ - var ctx = this; - process.nextTick(function(){ - calls.push('before'); - if (ctx.currentTest) { - calls.push('before test ' + ctx.currentTest.title); - } - done(); - }) - }) - - it('one', function(done){ - calls.should.eql([ - 'root before all' - , 'before all' - , 'parent before' - , 'before' - , 'before test one']); - calls.push('one'); - process.nextTick(done); - }) - - it('two', function(){ - calls.should.eql([ - 'root before all' - , 'before all' - , 'parent before' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test two']); - calls.push('two'); - }) - - it('three', function(){ - calls.should.eql([ - 'root before all' - , 'before all' - , 'parent before' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test two' - , 'two' - , 'after' - , 'after test two passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test three']); - calls.push('three'); - }) - - afterEach(function(done){ - var ctx = this; - process.nextTick(function(){ - calls.push('after'); - if (ctx.currentTest) { - calls.push('after test ' + ctx.currentTest.title + ' ' + ctx.currentTest.state); - } - done(); - }) - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/hook-sync-nested.spec.js b/tests/lib/mocha-3.1.0/test/hook-sync-nested.spec.js deleted file mode 100644 index b87c22298f..0000000000 --- a/tests/lib/mocha-3.1.0/test/hook-sync-nested.spec.js +++ /dev/null @@ -1,98 +0,0 @@ -describe('serial', function(){ - describe('nested', function(){ - var calls = []; - - beforeEach(function(){ - calls.push('parent before'); - if (this.currentTest) { - calls.push('parent before test ' + this.currentTest.title); - } - }) - - afterEach(function(){ - calls.push('parent after'); - if (this.currentTest) { - calls.push('parent after test ' + this.currentTest.title + ' ' + this.currentTest.state); - } - }); - - it('foo', function(){ - calls.should.eql([ - 'parent before' - , 'parent before test foo']); - calls.push('foo'); - }) - - it('bar', function(){ - calls.should.eql([ - 'parent before' - , 'parent before test foo' - , 'foo' - , 'parent after' - , 'parent after test foo passed' - , 'parent before' - , 'parent before test bar']); - }) - - describe('hooks', function(){ - beforeEach(function(){ - calls.push('before'); - if (this.currentTest) { - calls.push('before test ' + this.currentTest.title); - } - }) - - it('one', function(){ - calls.should.eql([ - 'parent before' - , 'parent before test foo' - , 'foo' - , 'parent after' - , 'parent after test foo passed' - , 'parent before' - , 'parent before test bar' - , 'parent after' - , 'parent after test bar passed' - , 'parent before' - , 'parent before test one' - , 'before' - , 'before test one']); - calls.push('one'); - }) - - it('two', function(){ - calls.should.eql([ - 'parent before' - , 'parent before test foo' - , 'foo' - , 'parent after' - , 'parent after test foo passed' - , 'parent before' - , 'parent before test bar' - , 'parent after' - , 'parent after test bar passed' - , 'parent before' - , 'parent before test one' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent after test one passed' - , 'parent before' - , 'parent before test two' - , 'before' - , 'before test two']); - calls.push('two'); - }); - - afterEach(function(){ - calls.push('after'); - if (this.currentTest) { - calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state); - } - }) - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/hook-sync.spec.js b/tests/lib/mocha-3.1.0/test/hook-sync.spec.js deleted file mode 100644 index 1d40f5d0c0..0000000000 --- a/tests/lib/mocha-3.1.0/test/hook-sync.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -describe('serial', function(){ - var calls = []; - - beforeEach(function(){ - calls.push('parent before'); - }) - - afterEach(function(){ - calls.push('parent after'); - }) - - describe('hooks', function(){ - beforeEach(function(){ - calls.push('before'); - if (this.currentTest) { - calls.push('before test ' + this.currentTest.title); - } - }) - - it('one', function(){ - calls.should.eql([ - 'parent before' - , 'before' - , 'before test one']); - calls.push('one'); - }) - - it('two', function(){ - calls.should.eql([ - 'parent before' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test two']); - calls.push('two'); - }) - - it('three', function(){ - calls.should.eql([ - 'parent before' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test two' - , 'two' - , 'after' - , 'after test two passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test three']); - calls.push('three'); - }) - - afterEach(function(){ - calls.push('after'); - if (this.currentTest) { - calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state); - } - }) - - after(function(){ - calls.should.eql([ - 'parent before' - , 'before' - , 'before test one' - , 'one' - , 'after' - , 'after test one passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test two' - , 'two' - , 'after' - , 'after test two passed' - , 'parent after' - , 'parent before' - , 'before' - , 'before test three' - , 'three' - , 'after' - , 'after test three passed' - , 'parent after']); - }) - }) -}) diff --git a/tests/lib/mocha-3.1.0/test/hook-timeout.spec.js b/tests/lib/mocha-3.1.0/test/hook-timeout.spec.js deleted file mode 100644 index 155c1e95a6..0000000000 --- a/tests/lib/mocha-3.1.0/test/hook-timeout.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -before(function(done){ - this.timeout(100); - setTimeout(done, 50); -}) - -it('should work', function(done) { - done(); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js deleted file mode 100644 index 14e114e959..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('spec 1', function() { - it('should not blame me', function() { }); -}); -describe('spec 2', function() { - before(function(done) { - process.nextTick(function () { - throw new Error('before hook error'); - }); - }); - it('skipped'); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js deleted file mode 100644 index 567dfef26b..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('spec 1', function() { - it('should not blame me', function() { }); -}); -describe('spec 2', function() { - before(function() { - throw new Error('before hook error'); - }); - it('skipped'); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-before.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-before.fixture.js deleted file mode 100644 index 80d4adb61a..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-before.fixture.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('suite', function() { - before(function(done) { - setTimeout(done, 10); - setTimeout(done, 30); - }); - - it('test1', function(done) { - setTimeout(done, 50); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-beforeEach.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-beforeEach.fixture.js deleted file mode 100644 index 9b4724dea1..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-beforeEach.fixture.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('suite', function() { - beforeEach(function(done) { - setTimeout(done, 10); - setTimeout(done, 20); - }); - - it('test1', function(done) { - setTimeout(done, 50); - }); - - it('test2', function(done) { - setTimeout(done, 50); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-specs.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-specs.fixture.js deleted file mode 100644 index 82197061f1..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done-specs.fixture.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('suite', function() { - it('test1', function(done) { - done(); - setTimeout(done, 10); - }); - - it('test2', function(done) { - setTimeout(done, 20); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/async-only-async.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/async-only-async.fixture.js deleted file mode 100644 index 5387d169b7..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/async-only-async.fixture.js +++ /dev/null @@ -1,3 +0,0 @@ -it('should pass', function(done){ - done(); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/async-only-sync.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/async-only-sync.fixture.js deleted file mode 100644 index d0dd9fa828..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/async-only-sync.fixture.js +++ /dev/null @@ -1 +0,0 @@ -it('throws an error', function() {}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/bail.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/bail.fixture.js deleted file mode 100644 index 32d17e9aa8..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/bail.fixture.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('suite1', function() { - it('should display this spec', function() {}); - - it('should only display this error', function(done) { - throw new Error('this should be displayed'); - }); - - it('should not display this error', function(done) { - throw new Error('this should not be displayed'); - }); -}); - -describe('suite2', function() { - before(function(done) { - throw new Error('this hook should not be displayed'); - }); - - it('should not display this error', function(done) { - throw new Error('this should not be displayed'); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/delay-fail.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/delay-fail.fixture.js deleted file mode 100644 index 1475c918d4..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/delay-fail.fixture.js +++ /dev/null @@ -1,5 +0,0 @@ -setTimeout(function() { - throw new Error('oops'); - it('test', function() {}); - run(); -}, 100); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/grep.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/grep.fixture.js deleted file mode 100644 index 94785dc7db..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/grep.fixture.js +++ /dev/null @@ -1,17 +0,0 @@ -describe('grep', function() { - describe('Match', function() { - it('should run', function(){}); - it('should also run', function() {}); - }); - - describe('match', function() { - it('should run', function(){}); - it('should also run', function() {}); - }); - - describe('fail', function() { - it('should not be ran', function() { - throw new Error('Spec should not run'); - }); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/bdd.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/bdd.fixture.js deleted file mode 100644 index 783ce19b0b..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/bdd.fixture.js +++ /dev/null @@ -1,71 +0,0 @@ -describe.only('should run this suite', function() { - it('should run this test', function() {}); - - it('should run this test', function() {}); - - it('should run this test', function() {}); -}); - -describe('should not run this suite', function() { - it('should not run this test', function() { - (true).should.equal(false); - }); - - it('should not run this test', function() { - (true).should.equal(false); - }); - - it('should not run this test', function() { - (true).should.equal(false); - }); -}); - -describe.only('should run this suite too', function() { - describe('should run this nested suite', function () { - it('should run this test', function() {}); - - it('should run this test', function() {}); - - it('should run this test', function() {}); - }); -}); - -describe.only('should run this suite, even', function() { - describe('should run this nested suite, even', function () { - describe('should run this doubly-nested suite!', function () { - it('should run this test', function() {}); - - it('should run this test', function() {}); - - it('should run this test', function() {}); - }); - }); -}); - - -describe('should run this suite with an exclusive test', function() { - it.only('should run this test', function () {}); - - describe('should not run this nested suite', function () { - describe.only('should not run this doubly-nested suite', function () { - it('should not run this test', function() {}); - - it('should not run this test', function() {}); - - it('should not run this test', function() {}); - }); - }); -}); - -describe('should run this suite with an exclusive test (reverse order)', function() { - describe('should not run this nested suite', function () { - describe.only('should not run this doubly-nested suite', function () { - it('should not run this test', function() {}); - - it('should not run this test', function() {}); - - it('should not run this test', function() {}); - }); - }); - it.only('should run this test', function () {}); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/qunit.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/qunit.fixture.js deleted file mode 100644 index 9fa95f440b..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/qunit.fixture.js +++ /dev/null @@ -1,26 +0,0 @@ -suite.only('should run all tests in this suite'); - -test('should run this test #1', function() {}); - -test('should run this test #2', function() {}); - -test('should run this test #3', function() {}); - -test('should run this test #4', function() {}); - -test('should run this test #5', function() {}); - - -suite('should not run any of this suite\'s tests'); - -test('should not run this test', function() { - (false).should.equal(true); -}); - -test('should not run this test', function() { - (false).should.equal(true); -}); - -test('should not run this test', function() { - (false).should.equal(true); -});
\ No newline at end of file diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/tdd.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/tdd.fixture.js deleted file mode 100644 index 129a9e5d74..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/only/tdd.fixture.js +++ /dev/null @@ -1,35 +0,0 @@ -suite.only('should run all tests in this tdd suite', function() { - test('should run this test #1', function() {}); - - test('should run this test #2', function() {}); - - test('should run this test #3', function() {}); - - test('should run this test #4', function() {}); -}); - -suite('should not run this suite', function() { - test('should not run this test', function() { - (true).should.equal(false); - }); - - test('should not run this test', function() { - (true).should.equal(false); - }); - - test('should not run this test', function() { - (true).should.equal(false); - }); -}); - -suite.only('should run this suite too', function() { - suite('should run this nested suite', function () { - test('should run this test', function() {}); - - test('should run this test', function() {}); - - test('should run this test', function() {}); - - test('should run this test', function() {}); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/sort-beta.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/options/sort-beta.fixture.js deleted file mode 100644 index 0951f49038..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/sort-beta.fixture.js +++ /dev/null @@ -1,5 +0,0 @@ -describe('beta', function(){ - it('should be executed second', function(){ - global.beta = 1; - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/passing.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/passing.fixture.js deleted file mode 100644 index df91b3e501..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/passing.fixture.js +++ /dev/null @@ -1,11 +0,0 @@ -var assert = require('assert'); - -describe('suite', function() { - it('test1', function() { - assert(true); - }); - - it('test2', function() { - assert(true); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-before.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-before.fixture.js deleted file mode 100644 index 114db36d88..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-before.fixture.js +++ /dev/null @@ -1,16 +0,0 @@ -describe('skip in before', function() { - before(function(done) { - var self = this; - setTimeout(function() { - self.skip(); - }, 50); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js deleted file mode 100644 index b8db22b94a..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js +++ /dev/null @@ -1,16 +0,0 @@ -describe('skip in beforeEach', function() { - beforeEach(function(done) { - var self = this; - setTimeout(function() { - self.skip(); - }, 50); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-spec.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-spec.fixture.js deleted file mode 100644 index 6096c59d2a..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-async-spec.fixture.js +++ /dev/null @@ -1,12 +0,0 @@ -describe('skip in test', function() { - it('should skip async', function(done) { - var self = this; - setTimeout(function() { - self.skip(); - }, 50); - }); - - it('should run other tests in the suite', function() { - // Do nothing - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-before.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-before.fixture.js deleted file mode 100644 index 35152e27f4..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-before.fixture.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('skip in before', function() { - before(function() { - this.skip(); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js deleted file mode 100644 index 8d1c442ce2..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('skip in beforeEach', function() { - beforeEach(function() { - this.skip(); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); - - it('should never run this test', function() { - throw new Error('never thrown'); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-spec.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-spec.fixture.js deleted file mode 100644 index e2bbb739b3..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/skip-sync-spec.fixture.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('skip in test', function() { - it('should skip immediately', function() { - this.skip(); - throw new Error('never thrown'); - }); - - it('should run other tests in the suite', function() { - // Do nothing - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/spec.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/spec.fixture.js deleted file mode 100644 index 084dd33588..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/pending/spec.fixture.js +++ /dev/null @@ -1,3 +0,0 @@ -describe('suite', function() { - it('pending spec'); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/1794/issue-1794.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/1794/issue-1794.fixture.js deleted file mode 100644 index 1a1637f30a..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/1794/issue-1794.fixture.js +++ /dev/null @@ -1,3 +0,0 @@ -test('pass', function() { - // pass -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-1327.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-1327.fixture.js deleted file mode 100644 index 43d5553762..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-1327.fixture.js +++ /dev/null @@ -1,15 +0,0 @@ -it('test 1', function() { - console.log('testbody1'); - process.nextTick(function() { - throw 'Too bad'; - }); -}); - -it('test 2', function() { - console.log('testbody2'); -}); - -it('test 3', function() { - console.log('testbody3'); - throw new Error('OUCH'); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2406.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2406.fixture.js deleted file mode 100644 index c800228f1e..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2406.fixture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('outer describe', function() { - it('should not run this test', function() {}); - describe('this suite should not run', function() { - it('should not run this test', function() {}); - }); - describe.only('this .only suite should run', function() { - describe('this suite should run', function() { - it('should run this test in a nested suite', function() {}); - }); - it('should run this test', function() {}); - }); - describe('this suite should not run', function() { - it('should not run this test', function() {}); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2417.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2417.fixture.js deleted file mode 100644 index e14aab09db..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2417.fixture.js +++ /dev/null @@ -1,7 +0,0 @@ -describe('outer describe', function() { - describe.only('outer describe.only', function() { - it.only('inner it.only', function() { - // should run and exit without error - }); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/timeout.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/timeout.fixture.js deleted file mode 100644 index d8c99b2bc3..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/timeout.fixture.js +++ /dev/null @@ -1,17 +0,0 @@ -describe('timeout', function(){ - this.timeout(1); - - it('should be honored with sync suites', function() { - sleep(2); - }); - - it('should be honored with async suites', function(done) { - sleep(2); - done(); - }); - - function sleep(ms) { - var start = Date.now(); - while (start + ms > Date.now()); - } -}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/uncaught-hook.fixture.js b/tests/lib/mocha-3.1.0/test/integration/fixtures/uncaught-hook.fixture.js deleted file mode 100644 index 9adcb3f726..0000000000 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/uncaught-hook.fixture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('uncaught', function() { - beforeEach(function(done) { - process.nextTick(function() { - throw new Error('oh noes'); - done(); - }); - }); - - it('test', function(done) { - process.nextTick(function() { - throw new Error("I'm uncaught!"); - done(); - }); - }); -}); diff --git a/tests/lib/mocha-3.1.0/test/reporters/json.spec.js b/tests/lib/mocha-3.1.0/test/reporters/json.spec.js deleted file mode 100644 index e7b8955757..0000000000 --- a/tests/lib/mocha-3.1.0/test/reporters/json.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -var Mocha = require('../../') - , Suite = Mocha.Suite - , Runner = Mocha.Runner - , Test = Mocha.Test; - -describe('json reporter', function(){ - var suite, runner; - - beforeEach(function(){ - var mocha = new Mocha({ - reporter: 'json' - }); - suite = new Suite('JSON suite', 'root'); - runner = new Runner(suite); - var mochaReporter = new mocha._reporter(runner); - }); - - it('should have 1 test failure', function(done){ - var testTitle = 'json test 1'; - var error = { message: 'oh shit' }; - - suite.addTest(new Test(testTitle, function (done) { - done(new Error(error.message)); - })); - - runner.run(function(failureCount) { - failureCount.should.be.exactly(1); - runner.should.have.property('testResults'); - runner.testResults.should.have.property('failures'); - runner.testResults.failures.should.be.an.instanceOf(Array); - runner.testResults.failures.should.have.a.lengthOf(1); - - var failure = runner.testResults.failures[0]; - failure.should.have.property('title', testTitle); - failure.err.message.should.equal(error.message); - failure.should.have.properties('err'); - - done(); - }); - }); - - it('should have 1 test pending', function(done) { - var testTitle = 'json test 1'; - - suite.addTest(new Test(testTitle)); - - runner.run(function(failureCount) { - failureCount.should.be.exactly(0); - runner.should.have.property('testResults'); - runner.testResults.should.have.property('pending'); - runner.testResults.pending.should.be.an.instanceOf(Array); - runner.testResults.pending.should.have.a.lengthOf(1); - - var pending = runner.testResults.pending[0]; - pending.should.have.property('title', testTitle); - - done(); - }); - }) - -}); diff --git a/tests/lib/mocha-3.1.0/test/sanity/sanity.spec.js b/tests/lib/mocha-3.1.0/test/sanity/sanity.spec.js deleted file mode 100644 index 59d5896515..0000000000 --- a/tests/lib/mocha-3.1.0/test/sanity/sanity.spec.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var assert = require('assert'); - -describe('a production installation of Mocha', function() { - it('should be able to execute a test', function() { - assert.ok(true); - }); -}); diff --git a/tests/lib/mocha-3.1.0/.editorconfig b/tests/lib/mocha-3.1.2/.editorconfig index e3a4859eeb..e3a4859eeb 100644 --- a/tests/lib/mocha-3.1.0/.editorconfig +++ b/tests/lib/mocha-3.1.2/.editorconfig diff --git a/tests/lib/mocha-3.1.2/.eslintignore b/tests/lib/mocha-3.1.2/.eslintignore new file mode 100644 index 0000000000..3e4b026a81 --- /dev/null +++ b/tests/lib/mocha-3.1.2/.eslintignore @@ -0,0 +1,2 @@ +lib/to-iso-string/**/*.js +mocha.js diff --git a/tests/lib/mocha-3.1.2/.eslintrc.yaml b/tests/lib/mocha-3.1.2/.eslintrc.yaml new file mode 100644 index 0000000000..911f22c681 --- /dev/null +++ b/tests/lib/mocha-3.1.2/.eslintrc.yaml @@ -0,0 +1,11 @@ +env: + node: true + browser: true +parserOptions: + ecmaVersion: 5 + sourceType: script +extends: semistandard +rules: + strict: + - error + - safe diff --git a/tests/lib/mocha-3.1.0/.gitignore b/tests/lib/mocha-3.1.2/.gitignore index fa1c0b0ccf..fa1c0b0ccf 100644 --- a/tests/lib/mocha-3.1.0/.gitignore +++ b/tests/lib/mocha-3.1.2/.gitignore diff --git a/tests/lib/mocha-3.1.0/.mailmap b/tests/lib/mocha-3.1.2/.mailmap index 528a26775e..528a26775e 100644 --- a/tests/lib/mocha-3.1.0/.mailmap +++ b/tests/lib/mocha-3.1.2/.mailmap diff --git a/tests/lib/mocha-3.1.0/.npmignore b/tests/lib/mocha-3.1.2/.npmignore index e3216decb2..e3216decb2 100644 --- a/tests/lib/mocha-3.1.0/.npmignore +++ b/tests/lib/mocha-3.1.2/.npmignore diff --git a/tests/lib/mocha-3.1.0/.travis.yml b/tests/lib/mocha-3.1.2/.travis.yml index 29b4c419e5..29b4c419e5 100644 --- a/tests/lib/mocha-3.1.0/.travis.yml +++ b/tests/lib/mocha-3.1.2/.travis.yml diff --git a/tests/lib/mocha-3.1.0/CHANGELOG.md b/tests/lib/mocha-3.1.2/CHANGELOG.md index 27d04fac00..da0fb42933 100644 --- a/tests/lib/mocha-3.1.0/CHANGELOG.md +++ b/tests/lib/mocha-3.1.2/CHANGELOG.md @@ -1,3 +1,30 @@ +# 3.1.2 / 2016-10-10 + +## :bug: Bug Fix + +- [#2528]: Recovery gracefully if an `Error`'s `stack` property isn't writable ([@boneskull]) + +[#2528]: https://github.com/mochajs/mocha/issues/2528 + +# 3.1.1 / 2016-10-09 + +## :bug: Bug Fix + +- [#1417]: Don't report `done()` was called multiple times when it wasn't ([@frankleonrose]) + +## :nut_and_bolt: Other + +- [#2490]: Lint with [semistandard](https://npmjs.com/package/semistandard) config ([@makepanic]) +- [#2525]: Lint all `.js` files ([@boneskull]) +- [#2524]: Provide workaround for developers unable to run browser tests on macOS Sierra ([@boneskull]) + +[#1417]: https://github.com/mochajs/mocha/issues/1417 +[#2490]: https://github.com/mochajs/mocha/issues/2490 +[#2525]: https://github.com/mochajs/mocha/issues/2525 +[#2524]: https://github.com/mochajs/mocha/issues/2524 +[@makepanic]: https://github.com/makepanic +[@frankleonrose]: https://github.com/frankleonrose + # 3.1.0 / 2016-09-27 ## :tada: Enhancement @@ -1113,7 +1140,7 @@ Thanks @entertainyou, @SimenB, @just-paja for the heads-up. * Added js API. Closes #265 * Added: initial run of tests with `--watch`. Closes #345 * Added: mark `location` as a global on the CS. Closes #311 - * Added `markdown` reporter (GitHub flavour) + * Added `markdown` reporter (github flavour) * Added: scrolling menu to coverage.html. Closes #335 * Added source line to html report for Safari [Tyson Tate] * Added "min" reporter, useful for `--watch` [Jakub Nešetřil] diff --git a/tests/lib/mocha-3.1.0/CONTRIBUTING.md b/tests/lib/mocha-3.1.2/CONTRIBUTING.md index 6d172f0800..6d172f0800 100644 --- a/tests/lib/mocha-3.1.0/CONTRIBUTING.md +++ b/tests/lib/mocha-3.1.2/CONTRIBUTING.md diff --git a/tests/lib/mocha-3.1.0/LICENSE b/tests/lib/mocha-3.1.2/LICENSE index 9919641276..9919641276 100644 --- a/tests/lib/mocha-3.1.0/LICENSE +++ b/tests/lib/mocha-3.1.2/LICENSE diff --git a/tests/lib/mocha-3.1.0/Makefile b/tests/lib/mocha-3.1.2/Makefile index 25d84f5c1d..611211abde 100644 --- a/tests/lib/mocha-3.1.0/Makefile +++ b/tests/lib/mocha-3.1.2/Makefile @@ -25,7 +25,7 @@ clean: lint: @printf "==> [Test :: Lint]\n" - $(ESLINT) browser-entry.js index.js karma.conf.js bin/mocha bin/_mocha "lib/**/*.js" "scripts/**/*.js" test + $(ESLINT) . test-node: test-bdd test-tdd test-qunit test-exports test-unit test-integration test-jsapi test-compilers test-glob test-requires test-reporters test-only test-global-only diff --git a/tests/lib/mocha-3.1.0/README.md b/tests/lib/mocha-3.1.2/README.md index e2d0bb998a..e2d0bb998a 100644 --- a/tests/lib/mocha-3.1.0/README.md +++ b/tests/lib/mocha-3.1.2/README.md diff --git a/tests/lib/mocha-3.1.0/appveyor.yml b/tests/lib/mocha-3.1.2/appveyor.yml index 539b8b073d..539b8b073d 100644 --- a/tests/lib/mocha-3.1.0/appveyor.yml +++ b/tests/lib/mocha-3.1.2/appveyor.yml diff --git a/tests/lib/mocha-3.1.0/assets/mocha-banner-192.png b/tests/lib/mocha-3.1.2/assets/mocha-banner-192.png Binary files differindex 15e076e119..15e076e119 100644 --- a/tests/lib/mocha-3.1.0/assets/mocha-banner-192.png +++ b/tests/lib/mocha-3.1.2/assets/mocha-banner-192.png diff --git a/tests/lib/mocha-3.1.0/assets/mocha-banner.svg b/tests/lib/mocha-3.1.2/assets/mocha-banner.svg index 9f54009600..9f54009600 100644 --- a/tests/lib/mocha-3.1.0/assets/mocha-banner.svg +++ b/tests/lib/mocha-3.1.2/assets/mocha-banner.svg diff --git a/tests/lib/mocha-3.1.0/assets/mocha-logo-128.png b/tests/lib/mocha-3.1.2/assets/mocha-logo-128.png Binary files differindex d4dbf34603..d4dbf34603 100644 --- a/tests/lib/mocha-3.1.0/assets/mocha-logo-128.png +++ b/tests/lib/mocha-3.1.2/assets/mocha-logo-128.png diff --git a/tests/lib/mocha-3.1.0/assets/mocha-logo-192.png b/tests/lib/mocha-3.1.2/assets/mocha-logo-192.png Binary files differindex 69fbbff090..69fbbff090 100644 --- a/tests/lib/mocha-3.1.0/assets/mocha-logo-192.png +++ b/tests/lib/mocha-3.1.2/assets/mocha-logo-192.png diff --git a/tests/lib/mocha-3.1.0/assets/mocha-logo-64.png b/tests/lib/mocha-3.1.2/assets/mocha-logo-64.png Binary files differindex 10403ff294..10403ff294 100644 --- a/tests/lib/mocha-3.1.0/assets/mocha-logo-64.png +++ b/tests/lib/mocha-3.1.2/assets/mocha-logo-64.png diff --git a/tests/lib/mocha-3.1.0/assets/mocha-logo.svg b/tests/lib/mocha-3.1.2/assets/mocha-logo.svg index e907e3167e..e907e3167e 100644 --- a/tests/lib/mocha-3.1.0/assets/mocha-logo.svg +++ b/tests/lib/mocha-3.1.2/assets/mocha-logo.svg diff --git a/tests/lib/mocha-3.1.0/bin/.eslintrc b/tests/lib/mocha-3.1.2/bin/.eslintrc index db7424631c..db7424631c 100644 --- a/tests/lib/mocha-3.1.0/bin/.eslintrc +++ b/tests/lib/mocha-3.1.2/bin/.eslintrc diff --git a/tests/lib/mocha-3.1.0/bin/_mocha b/tests/lib/mocha-3.1.2/bin/_mocha index 1d3539e8f0..6cfc094ba1 100644 --- a/tests/lib/mocha-3.1.0/bin/_mocha +++ b/tests/lib/mocha-3.1.2/bin/_mocha @@ -1,4 +1,5 @@ #!/usr/bin/env node +'use strict'; /* eslint no-unused-vars: off */ @@ -114,7 +115,7 @@ program._name = 'mocha'; program .command('init <path>') .description('initialize a client-side mocha setup at <path>') - .action(function(path) { + .action(function (path) { var mkdir = require('mkdirp'); mkdir.sync(path); var css = fs.readFileSync(join(__dirname, '..', 'mocha.css')); @@ -129,13 +130,13 @@ program // --globals -program.on('globals', function(val) { +program.on('globals', function (val) { globals = globals.concat(list(val)); }); // --reporters -program.on('reporters', function() { +program.on('reporters', function () { console.log(); console.log(' dot - dot matrix'); console.log(' doc - html documentation'); @@ -148,7 +149,7 @@ program.on('reporters', function() { console.log(' xunit - xunit reporter'); console.log(' min - minimal reporter (great with --watch)'); console.log(' json-stream - newline delimited json events'); - console.log(' markdown - markdown documentation (GitHub flavour)'); + console.log(' markdown - markdown documentation (github flavour)'); console.log(' nyan - nyan cat!'); console.log(); process.exit(); @@ -156,9 +157,9 @@ program.on('reporters', function() { // --interfaces -program.on('interfaces', function() { +program.on('interfaces', function () { console.log(''); - interfaceNames.forEach(function(interfaceName) { + interfaceNames.forEach(function (interfaceName) { console.log(' ' + interfaceName); }); console.log(''); @@ -169,7 +170,7 @@ program.on('interfaces', function() { module.paths.push(cwd, join(cwd, 'node_modules')); -program.on('require', function(mod) { +program.on('require', function (mod) { var abs = exists(mod) || exists(mod + '.js'); if (abs) { mod = resolve(mod); @@ -194,7 +195,7 @@ Error.stackTraceLimit = Infinity; // TODO: config var reporterOptions = {}; if (program.reporterOptions !== undefined) { - program.reporterOptions.split(',').forEach(function(opt) { + program.reporterOptions.split(',').forEach(function (opt) { var L = opt.split('='); if (L.length > 2 || L.length === 0) { throw new Error("invalid reporter option '" + opt + "'"); @@ -324,7 +325,7 @@ if (program.retries) { // custom compiler support var extensions = ['js']; -program.compilers.forEach(function(c) { +program.compilers.forEach(function (c) { var idx = c.indexOf(':'); var ext = c.slice(0, idx); var mod = c.slice(idx + 1); @@ -339,7 +340,7 @@ program.compilers.forEach(function(c) { // requires -requires.forEach(function(mod) { +requires.forEach(function (mod) { require(mod); }); @@ -357,7 +358,7 @@ if (!args.length) { args.push('test'); } -args.forEach(function(arg) { +args.forEach(function (arg) { var newFiles; try { newFiles = utils.lookupFiles(arg, extensions, program.recursive); @@ -380,7 +381,7 @@ if (!files.length) { // resolve -files = files.map(function(path) { +files = files.map(function (path) { return resolve(path); }); @@ -398,7 +399,7 @@ var rerun; if (program.watch) { console.log(); hideCursor(); - process.on('SIGINT', function() { + process.on('SIGINT', function () { showCursor(); console.log('\n'); process.exit(130); @@ -407,11 +408,11 @@ if (program.watch) { var watchFiles = utils.files(cwd, [ 'js' ].concat(program.watchExtensions)); var runAgain = false; - loadAndRun = function loadAndRun() { + loadAndRun = function loadAndRun () { try { mocha.files = files; runAgain = false; - runner = mocha.run(function() { + runner = mocha.run(function () { runner = null; if (runAgain) { rerun(); @@ -422,15 +423,15 @@ if (program.watch) { } }; - purge = function purge() { - watchFiles.forEach(function(file) { + purge = function purge () { + watchFiles.forEach(function (file) { delete require.cache[file]; }); }; loadAndRun(); - rerun = function rerun() { + rerun = function rerun () { purge(); stop(); if (!program.grep) { @@ -442,7 +443,7 @@ if (program.watch) { loadAndRun(); }; - utils.watch(watchFiles, function() { + utils.watch(watchFiles, function () { runAgain = true; if (runner) { runner.abort(); @@ -457,17 +458,17 @@ if (program.watch) { runner = mocha.run(program.exit ? exit : exitLater); } -function exitLater(code) { - process.on('exit', function() { +function exitLater (code) { + process.on('exit', function () { process.exit(Math.min(code, 255)); }); } -function exit(code) { +function exit (code) { // flush output for Node.js Windows pipe bug // https://github.com/joyent/node/issues/6247 is just one bug example // https://github.com/visionmedia/mocha/issues/333 has a good discussion - function done() { + function done () { if (!(draining--)) { process.exit(Math.min(code, 255)); } @@ -476,7 +477,7 @@ function exit(code) { var draining = 0; var streams = [process.stdout, process.stderr]; - streams.forEach(function(stream) { + streams.forEach(function (stream) { // submit empty write request and wait for completion draining += 1; stream.write('', done); @@ -485,7 +486,7 @@ function exit(code) { done(); } -process.on('SIGINT', function() { +process.on('SIGINT', function () { runner.abort(); // This is a hack: @@ -498,7 +499,7 @@ process.on('SIGINT', function() { * Parse list. */ -function list(str) { +function list (str) { return str.split(/ *, */); } @@ -506,7 +507,7 @@ function list(str) { * Hide the cursor. */ -function hideCursor() { +function hideCursor () { process.stdout.write('\u001b[?25l'); } @@ -514,7 +515,7 @@ function hideCursor() { * Show the cursor. */ -function showCursor() { +function showCursor () { process.stdout.write('\u001b[?25h'); } @@ -522,7 +523,7 @@ function showCursor() { * Stop play()ing. */ -function stop() { +function stop () { process.stdout.write('\u001b[2K'); clearInterval(play.timer); } @@ -531,12 +532,12 @@ function stop() { * Play the given array of strings. */ -function play(arr, interval) { +function play (arr, interval) { var len = arr.length; interval = interval || 100; var i = 0; - play.timer = setInterval(function() { + play.timer = setInterval(function () { var str = arr[i++ % len]; process.stdout.write('\u001b[0G' + str); }, interval); diff --git a/tests/lib/mocha-3.1.0/bin/mocha b/tests/lib/mocha-3.1.2/bin/mocha index 0c16f0ee94..c6aaa97b00 100644 --- a/tests/lib/mocha-3.1.0/bin/mocha +++ b/tests/lib/mocha-3.1.2/bin/mocha @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + /** * This tiny wrapper file checks for known node flags and appends them * when found, before invoking the "real" _mocha(1) executable. @@ -14,7 +16,7 @@ var args = [path.join(__dirname, '_mocha')]; // Must be loaded here to handle node-specific options getOptions(); -process.argv.slice(2).forEach(function(arg) { +process.argv.slice(2).forEach(function (arg) { var flag = arg.split('=')[0]; switch (flag) { @@ -64,8 +66,8 @@ process.argv.slice(2).forEach(function(arg) { }); var proc = spawn(process.execPath, args, { stdio: 'inherit' }); -proc.on('exit', function(code, signal) { - process.on('exit', function() { +proc.on('exit', function (code, signal) { + process.on('exit', function () { if (signal) { process.kill(process.pid, signal); } else { @@ -75,7 +77,7 @@ proc.on('exit', function(code, signal) { }); // terminate children. -process.on('SIGINT', function() { +process.on('SIGINT', function () { proc.kill('SIGINT'); // calls runner.abort() proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die. }); diff --git a/tests/lib/mocha-3.1.0/bin/options.js b/tests/lib/mocha-3.1.2/bin/options.js index 9d1a18a23e..be5a60c9c3 100644 --- a/tests/lib/mocha-3.1.0/bin/options.js +++ b/tests/lib/mocha-3.1.2/bin/options.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Dependencies. */ @@ -14,17 +16,17 @@ module.exports = getOptions; * Get options. */ -function getOptions() { - var optsPath = process.argv.indexOf('--opts') !== -1 - ? process.argv[process.argv.indexOf('--opts') + 1] - : 'test/mocha.opts'; +function getOptions () { + var optsPath = process.argv.indexOf('--opts') === -1 + ? 'test/mocha.opts' + : process.argv[process.argv.indexOf('--opts') + 1]; try { var opts = fs.readFileSync(optsPath, 'utf8') .replace(/\\\s/g, '%20') .split(/\s/) .filter(Boolean) - .map(function(value) { + .map(function (value) { return value.replace(/%20/g, ' '); }); diff --git a/tests/lib/mocha-3.1.0/bower.json b/tests/lib/mocha-3.1.2/bower.json index e96cc9526d..e96cc9526d 100644 --- a/tests/lib/mocha-3.1.0/bower.json +++ b/tests/lib/mocha-3.1.2/bower.json diff --git a/tests/lib/mocha-3.1.0/browser-entry.js b/tests/lib/mocha-3.1.2/browser-entry.js index 789e686ae6..1d5ef5a1c4 100644 --- a/tests/lib/mocha-3.1.0/browser-entry.js +++ b/tests/lib/mocha-3.1.2/browser-entry.js @@ -1,4 +1,7 @@ +'use strict'; + /* eslint no-unused-vars: off */ +/* eslint-env commonjs */ /** * Shim process.stdout. @@ -35,12 +38,12 @@ var originalOnerrorHandler = global.onerror; * Revert to original onerror handler if previously defined. */ -process.removeListener = function(e, fn) { +process.removeListener = function (e, fn) { if (e === 'uncaughtException') { if (originalOnerrorHandler) { global.onerror = originalOnerrorHandler; } else { - global.onerror = function() {}; + global.onerror = function () {}; } var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn); if (i !== -1) { @@ -53,9 +56,9 @@ process.removeListener = function(e, fn) { * Implements uncaughtException listener. */ -process.on = function(e, fn) { +process.on = function (e, fn) { if (e === 'uncaughtException') { - global.onerror = function(err, url, line) { + global.onerror = function (err, url, line) { fn(new Error(err + ' (' + url + ':' + line + ')')); return !mocha.allowUncaught; }; @@ -71,7 +74,7 @@ mocha.suite.removeAllListeners('pre-require'); var immediateQueue = []; var immediateTimeout; -function timeslice() { +function timeslice () { var immediateStart = new Date().getTime(); while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) { immediateQueue.shift()(); @@ -87,7 +90,7 @@ function timeslice() { * High-performance override of Runner.immediately. */ -Mocha.Runner.immediately = function(callback) { +Mocha.Runner.immediately = function (callback) { immediateQueue.push(callback); if (!immediateTimeout) { immediateTimeout = setTimeout(timeslice, 0); @@ -99,8 +102,8 @@ Mocha.Runner.immediately = function(callback) { * This is useful when running tests in a browser because window.onerror will * only receive the 'message' attribute of the Error. */ -mocha.throwError = function(err) { - Mocha.utils.forEach(uncaughtExceptionHandlers, function(fn) { +mocha.throwError = function (err) { + Mocha.utils.forEach(uncaughtExceptionHandlers, function (fn) { fn(err); }); throw err; @@ -111,7 +114,7 @@ mocha.throwError = function(err) { * Normally this would happen in Mocha.prototype.loadFiles. */ -mocha.ui = function(ui) { +mocha.ui = function (ui) { Mocha.prototype.ui.call(this, ui); this.suite.emit('pre-require', global, null, this); return this; @@ -121,7 +124,7 @@ mocha.ui = function(ui) { * Setup mocha with the given setting options. */ -mocha.setup = function(opts) { +mocha.setup = function (opts) { if (typeof opts === 'string') { opts = { ui: opts }; } @@ -137,7 +140,7 @@ mocha.setup = function(opts) { * Run mocha, returning the Runner. */ -mocha.run = function(fn) { +mocha.run = function (fn) { var options = mocha.options; mocha.globals('location'); @@ -152,7 +155,7 @@ mocha.run = function(fn) { mocha.invert(); } - return Mocha.prototype.run.call(mocha, function(err) { + return Mocha.prototype.run.call(mocha, function (err) { // The DOM Document is not available in Web Workers. var document = global.document; if (document && document.getElementById('mocha') && options.noHighlighting !== true) { diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet index c722cfe8ae..c722cfe8ae 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet index c0b1f6bd82..c0b1f6bd82 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet index 14fa93b1b0..14fa93b1b0 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet index 18b48c0eeb..18b48c0eeb 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - describe.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - describe.tmSnippet index 041726c067..041726c067 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - describe.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - describe.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet index 72a3b0ee3a..72a3b0ee3a 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert.tmSnippet index 38d78ce2ec..38d78ce2ec 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_deepEqual.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_deepEqual.tmSnippet index 4204e4c4f2..4204e4c4f2 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_deepEqual.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_deepEqual.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_equal.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_equal.tmSnippet index 8f09805968..8f09805968 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_equal.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_equal.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_fail.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_fail.tmSnippet index 3e8dbe3b9e..3e8dbe3b9e 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_fail.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_fail.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_isFunction.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_isFunction.tmSnippet index 903d7f6fdf..903d7f6fdf 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_isFunction.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - assert_isFunction.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - setup.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - setup.tmSnippet index a30e650187..a30e650187 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - setup.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - setup.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - suite.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - suite.tmSnippet index 37cfd8a566..37cfd8a566 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - suite.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - suite.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - teardown.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - teardown.tmSnippet index 68fd441016..68fd441016 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - teardown.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - teardown.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - test.tmSnippet b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - test.tmSnippet index 279da8900d..279da8900d 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/Snippets/tdd - test.tmSnippet +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/Snippets/tdd - test.tmSnippet diff --git a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/info.plist b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/info.plist index 16f6587a6c..16f6587a6c 100755..100644 --- a/tests/lib/mocha-3.1.0/editors/JavaScript mocha.tmbundle/info.plist +++ b/tests/lib/mocha-3.1.2/editors/JavaScript mocha.tmbundle/info.plist diff --git a/tests/lib/mocha-3.1.0/images/error.png b/tests/lib/mocha-3.1.2/images/error.png Binary files differindex a07a1ba5ef..a07a1ba5ef 100755..100644 --- a/tests/lib/mocha-3.1.0/images/error.png +++ b/tests/lib/mocha-3.1.2/images/error.png diff --git a/tests/lib/mocha-3.1.0/images/ok.png b/tests/lib/mocha-3.1.2/images/ok.png Binary files differindex b3623a5994..b3623a5994 100755..100644 --- a/tests/lib/mocha-3.1.0/images/ok.png +++ b/tests/lib/mocha-3.1.2/images/ok.png diff --git a/tests/lib/mocha-3.1.0/index.js b/tests/lib/mocha-3.1.2/index.js index d2b7d19609..d2b7d19609 100644 --- a/tests/lib/mocha-3.1.0/index.js +++ b/tests/lib/mocha-3.1.2/index.js diff --git a/tests/lib/mocha-3.1.0/karma.conf.js b/tests/lib/mocha-3.1.2/karma.conf.js index 4aa108b27d..8a85bf35cb 100644 --- a/tests/lib/mocha-3.1.0/karma.conf.js +++ b/tests/lib/mocha-3.1.2/karma.conf.js @@ -4,8 +4,9 @@ var fs = require('fs'); var path = require('path'); var mkdirp = require('mkdirp'); var baseBundleDirpath = path.join(__dirname, '.karma'); +var osName = require('os-name'); -module.exports = function(config) { +module.exports = function (config) { var bundleDirpath; var cfg = { frameworks: [ @@ -31,12 +32,12 @@ module.exports = function(config) { }, browserify: { debug: true, - configure: function configure(b) { + configure: function configure (b) { b.ignore('glob') .ignore('fs') .ignore('path') .ignore('supports-color') - .on('bundled', function(err, content) { + .on('bundled', function (err, content) { if (!err && bundleDirpath) { // write bundle to directory for debugging fs.writeFileSync(path.join(bundleDirpath, @@ -47,7 +48,7 @@ module.exports = function(config) { }, reporters: ['spec'], colors: true, - browsers: ['PhantomJS'], + browsers: [osName() === 'macOS Sierra' ? 'Chrome' : 'PhantomJS'], logLevel: config.LOG_INFO, client: { mocha: { @@ -70,8 +71,8 @@ module.exports = function(config) { if (env.SAUCE_USERNAME && env.SAUCE_ACCESS_KEY) { // correlate build/tunnel with Travis sauceConfig = { - build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER - + ' (' + env.TRAVIS_BUILD_ID + ')', + build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER + + ' (' + env.TRAVIS_BUILD_ID + ')', tunnelIdentifier: env.TRAVIS_JOB_NUMBER }; console.error('Configured SauceLabs'); @@ -124,7 +125,7 @@ module.exports = function(config) { config.set(cfg); }; -function addSauceTests(cfg) { +function addSauceTests (cfg) { cfg.reporters.push('saucelabs'); cfg.customLaunchers = { diff --git a/tests/lib/mocha-3.1.2/lib/browser/.eslintrc.yaml b/tests/lib/mocha-3.1.2/lib/browser/.eslintrc.yaml new file mode 100644 index 0000000000..d85f537d3b --- /dev/null +++ b/tests/lib/mocha-3.1.2/lib/browser/.eslintrc.yaml @@ -0,0 +1,4 @@ +env: + node: false + browser: false + commonjs: true diff --git a/tests/lib/mocha-3.1.2/lib/browser/debug.js b/tests/lib/mocha-3.1.2/lib/browser/debug.js new file mode 100644 index 0000000000..3d12160f1a --- /dev/null +++ b/tests/lib/mocha-3.1.2/lib/browser/debug.js @@ -0,0 +1,7 @@ +'use strict'; + +function noop () {} + +module.exports = function () { + return noop; +}; diff --git a/tests/lib/mocha-3.1.0/lib/browser/events.js b/tests/lib/mocha-3.1.2/lib/browser/events.js index b4342f6202..e46a9f5f05 100644 --- a/tests/lib/mocha-3.1.0/lib/browser/events.js +++ b/tests/lib/mocha-3.1.2/lib/browser/events.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module exports. */ @@ -16,7 +18,7 @@ var objToString = Object.prototype.toString; * @param {*} val The value to test. * @return {boolean} true if the value is an array, otherwise false. */ -function isArray(val) { +function isArray (val) { return objToString.call(val) === '[object Array]'; } @@ -25,7 +27,7 @@ function isArray(val) { * * @api public */ -function EventEmitter() {} +function EventEmitter () {} /** * Add a listener. @@ -35,7 +37,7 @@ function EventEmitter() {} * @param {Function} fn Event handler. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.on = function(name, fn) { +EventEmitter.prototype.on = function (name, fn) { if (!this.$events) { this.$events = {}; } @@ -61,10 +63,10 @@ EventEmitter.prototype.addListener = EventEmitter.prototype.on; * @param {Function} fn Event handler. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.once = function(name, fn) { +EventEmitter.prototype.once = function (name, fn) { var self = this; - function on() { + function on () { self.removeListener(name, on); fn.apply(this, arguments); } @@ -83,7 +85,7 @@ EventEmitter.prototype.once = function(name, fn) { * @param {Function} fn Event handler. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.removeListener = function(name, fn) { +EventEmitter.prototype.removeListener = function (name, fn) { if (this.$events && this.$events[name]) { var list = this.$events[name]; @@ -121,7 +123,7 @@ EventEmitter.prototype.removeListener = function(name, fn) { * @param {string} name Event name. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.removeAllListeners = function(name) { +EventEmitter.prototype.removeAllListeners = function (name) { if (name === undefined) { this.$events = {}; return this; @@ -141,7 +143,7 @@ EventEmitter.prototype.removeAllListeners = function(name) { * @param {string} name Event name. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.listeners = function(name) { +EventEmitter.prototype.listeners = function (name) { if (!this.$events) { this.$events = {}; } @@ -164,7 +166,7 @@ EventEmitter.prototype.listeners = function(name) { * @param {string} name Event name. * @return {boolean} true if at least one handler was invoked, else false. */ -EventEmitter.prototype.emit = function(name) { +EventEmitter.prototype.emit = function (name) { if (!this.$events) { return false; } diff --git a/tests/lib/mocha-3.1.0/lib/browser/progress.js b/tests/lib/mocha-3.1.2/lib/browser/progress.js index 3186b6ec50..2b23656b99 100644 --- a/tests/lib/mocha-3.1.0/lib/browser/progress.js +++ b/tests/lib/mocha-3.1.2/lib/browser/progress.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Expose `Progress`. */ @@ -7,7 +9,7 @@ module.exports = Progress; /** * Initialize a new `Progress` indicator. */ -function Progress() { +function Progress () { this.percent = 0; this.size(0); this.fontSize(11); @@ -21,7 +23,7 @@ function Progress() { * @param {number} size * @return {Progress} Progress instance. */ -Progress.prototype.size = function(size) { +Progress.prototype.size = function (size) { this._size = size; return this; }; @@ -33,7 +35,7 @@ Progress.prototype.size = function(size) { * @param {string} text * @return {Progress} Progress instance. */ -Progress.prototype.text = function(text) { +Progress.prototype.text = function (text) { this._text = text; return this; }; @@ -45,7 +47,7 @@ Progress.prototype.text = function(text) { * @param {number} size * @return {Progress} Progress instance. */ -Progress.prototype.fontSize = function(size) { +Progress.prototype.fontSize = function (size) { this._fontSize = size; return this; }; @@ -56,7 +58,7 @@ Progress.prototype.fontSize = function(size) { * @param {string} family * @return {Progress} Progress instance. */ -Progress.prototype.font = function(family) { +Progress.prototype.font = function (family) { this._font = family; return this; }; @@ -67,7 +69,7 @@ Progress.prototype.font = function(family) { * @param {number} n * @return {Progress} Progress instance. */ -Progress.prototype.update = function(n) { +Progress.prototype.update = function (n) { this.percent = n; return this; }; @@ -78,7 +80,7 @@ Progress.prototype.update = function(n) { * @param {CanvasRenderingContext2d} ctx * @return {Progress} Progress instance. */ -Progress.prototype.draw = function(ctx) { +Progress.prototype.draw = function (ctx) { try { var percent = Math.min(this.percent, 100); var size = this._size; diff --git a/tests/lib/mocha-3.1.0/lib/browser/tty.js b/tests/lib/mocha-3.1.2/lib/browser/tty.js index 840d6699ee..c77f7e99a6 100644 --- a/tests/lib/mocha-3.1.0/lib/browser/tty.js +++ b/tests/lib/mocha-3.1.2/lib/browser/tty.js @@ -1,8 +1,10 @@ -exports.isatty = function isatty() { +'use strict'; + +exports.isatty = function isatty () { return true; }; -exports.getWindowSize = function getWindowSize() { +exports.getWindowSize = function getWindowSize () { if ('innerHeight' in global) { return [global.innerHeight, global.innerWidth]; } diff --git a/tests/lib/mocha-3.1.0/lib/context.js b/tests/lib/mocha-3.1.2/lib/context.js index 6d82fcadf4..019fe8891c 100644 --- a/tests/lib/mocha-3.1.0/lib/context.js +++ b/tests/lib/mocha-3.1.2/lib/context.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -15,7 +17,7 @@ module.exports = Context; * * @api private */ -function Context() {} +function Context () {} /** * Set or get the context `Runnable` to `runnable`. @@ -24,7 +26,7 @@ function Context() {} * @param {Runnable} runnable * @return {Context} */ -Context.prototype.runnable = function(runnable) { +Context.prototype.runnable = function (runnable) { if (!arguments.length) { return this._runnable; } @@ -39,7 +41,7 @@ Context.prototype.runnable = function(runnable) { * @param {number} ms * @return {Context} self */ -Context.prototype.timeout = function(ms) { +Context.prototype.timeout = function (ms) { if (!arguments.length) { return this.runnable().timeout(); } @@ -54,7 +56,7 @@ Context.prototype.timeout = function(ms) { * @param {boolean} enabled * @return {Context} self */ -Context.prototype.enableTimeouts = function(enabled) { +Context.prototype.enableTimeouts = function (enabled) { this.runnable().enableTimeouts(enabled); return this; }; @@ -66,7 +68,7 @@ Context.prototype.enableTimeouts = function(enabled) { * @param {number} ms * @return {Context} self */ -Context.prototype.slow = function(ms) { +Context.prototype.slow = function (ms) { this.runnable().slow(ms); return this; }; @@ -77,7 +79,7 @@ Context.prototype.slow = function(ms) { * @api private * @return {Context} self */ -Context.prototype.skip = function() { +Context.prototype.skip = function () { this.runnable().skip(); return this; }; @@ -89,7 +91,7 @@ Context.prototype.skip = function() { * @param {number} n * @return {Context} self */ -Context.prototype.retries = function(n) { +Context.prototype.retries = function (n) { if (!arguments.length) { return this.runnable().retries(); } @@ -103,8 +105,8 @@ Context.prototype.retries = function(n) { * @api private * @return {string} */ -Context.prototype.inspect = function() { - return JSON.stringify(this, function(key, val) { +Context.prototype.inspect = function () { + return JSON.stringify(this, function (key, val) { return key === 'runnable' || key === 'test' ? undefined : val; }, 2); }; diff --git a/tests/lib/mocha-3.1.0/lib/hook.js b/tests/lib/mocha-3.1.2/lib/hook.js index 0417e013cd..392a4cfb4d 100644 --- a/tests/lib/mocha-3.1.0/lib/hook.js +++ b/tests/lib/mocha-3.1.2/lib/hook.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -18,7 +20,7 @@ module.exports = Hook; * @param {Function} fn * @api private */ -function Hook(title, fn) { +function Hook (title, fn) { Runnable.call(this, title, fn); this.type = 'hook'; } @@ -35,7 +37,7 @@ inherits(Hook, Runnable); * @return {Error} * @api public */ -Hook.prototype.error = function(err) { +Hook.prototype.error = function (err) { if (!arguments.length) { err = this._error; this._error = null; diff --git a/tests/lib/mocha-3.1.0/lib/interfaces/bdd.js b/tests/lib/mocha-3.1.2/lib/interfaces/bdd.js index 830a5fe67a..33efc169a2 100644 --- a/tests/lib/mocha-3.1.0/lib/interfaces/bdd.js +++ b/tests/lib/mocha-3.1.2/lib/interfaces/bdd.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -21,10 +23,10 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.before = common.before; @@ -38,7 +40,7 @@ module.exports = function(suite) { * and/or tests. */ - context.describe = context.context = function(title, fn) { + context.describe = context.context = function (title, fn) { return common.suite.create({ title: title, file: file, @@ -50,7 +52,7 @@ module.exports = function(suite) { * Pending describe. */ - context.xdescribe = context.xcontext = context.describe.skip = function(title, fn) { + context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) { return common.suite.skip({ title: title, file: file, @@ -62,7 +64,7 @@ module.exports = function(suite) { * Exclusive suite. */ - context.describe.only = function(title, fn) { + context.describe.only = function (title, fn) { return common.suite.only({ title: title, file: file, @@ -76,7 +78,7 @@ module.exports = function(suite) { * acting as a thunk. */ - context.it = context.specify = function(title, fn) { + context.it = context.specify = function (title, fn) { var suite = suites[0]; if (suite.isPending()) { fn = null; @@ -91,7 +93,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.it.only = function(title, fn) { + context.it.only = function (title, fn) { return common.test.only(mocha, context.it(title, fn)); }; @@ -99,14 +101,14 @@ module.exports = function(suite) { * Pending test case. */ - context.xit = context.xspecify = context.it.skip = function(title) { + context.xit = context.xspecify = context.it.skip = function (title) { context.it(title); }; /** * Number of attempts to retry. */ - context.it.retries = function(n) { + context.it.retries = function (n) { context.retries(n); }; }); diff --git a/tests/lib/mocha-3.1.0/lib/interfaces/common.js b/tests/lib/mocha-3.1.2/lib/interfaces/common.js index 447458487b..aec6b0d29a 100644 --- a/tests/lib/mocha-3.1.0/lib/interfaces/common.js +++ b/tests/lib/mocha-3.1.2/lib/interfaces/common.js @@ -10,7 +10,7 @@ var Suite = require('../suite'); * @param {Mocha} mocha * @return {Object} An object containing common functions. */ -module.exports = function(suites, context, mocha) { +module.exports = function (suites, context, mocha) { return { /** * This is only present if flag --delay is passed into Mocha. It triggers @@ -19,8 +19,8 @@ module.exports = function(suites, context, mocha) { * @param {Suite} suite The root wuite. * @return {Function} A function which runs the root suite */ - runWithSuite: function runWithSuite(suite) { - return function run() { + runWithSuite: function runWithSuite (suite) { + return function run () { suite.run(); }; }, @@ -31,7 +31,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - before: function(name, fn) { + before: function (name, fn) { suites[0].beforeAll(name, fn); }, @@ -41,7 +41,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - after: function(name, fn) { + after: function (name, fn) { suites[0].afterAll(name, fn); }, @@ -51,7 +51,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - beforeEach: function(name, fn) { + beforeEach: function (name, fn) { suites[0].beforeEach(name, fn); }, @@ -61,7 +61,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - afterEach: function(name, fn) { + afterEach: function (name, fn) { suites[0].afterEach(name, fn); }, @@ -73,7 +73,7 @@ module.exports = function(suites, context, mocha) { * @param {Object} opts * @returns {Suite} */ - only: function only(opts) { + only: function only (opts) { mocha.options.hasOnly = true; opts.isOnly = true; return this.create(opts); @@ -86,7 +86,7 @@ module.exports = function(suites, context, mocha) { * @param {Object} opts * @returns {Suite} */ - skip: function skip(opts) { + skip: function skip (opts) { opts.pending = true; return this.create(opts); }, @@ -101,7 +101,7 @@ module.exports = function(suites, context, mocha) { * @param {boolean} [opts.isOnly] Is Suite exclusive? * @returns {Suite} */ - create: function create(opts) { + create: function create (opts) { var suite = Suite.create(suites[0], opts.title); suite.pending = Boolean(opts.pending); suite.file = opts.file; @@ -130,7 +130,7 @@ module.exports = function(suites, context, mocha) { * @param {Function} test * @returns {*} */ - only: function(mocha, test) { + only: function (mocha, test) { test.parent._onlyTests = test.parent._onlyTests.concat(test); mocha.options.hasOnly = true; return test; @@ -141,7 +141,7 @@ module.exports = function(suites, context, mocha) { * * @param {string} title */ - skip: function(title) { + skip: function (title) { context.test(title); }, @@ -150,7 +150,7 @@ module.exports = function(suites, context, mocha) { * * @param {number} n */ - retries: function(n) { + retries: function (n) { context.retries(n); } } diff --git a/tests/lib/mocha-3.1.0/lib/interfaces/exports.js b/tests/lib/mocha-3.1.2/lib/interfaces/exports.js index 7db6e47c97..debfaee3b8 100644 --- a/tests/lib/mocha-3.1.0/lib/interfaces/exports.js +++ b/tests/lib/mocha-3.1.2/lib/interfaces/exports.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -22,12 +24,12 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; suite.on('require', visit); - function visit(obj, file) { + function visit (obj, file) { var suite; for (var key in obj) { if (typeof obj[key] === 'function') { diff --git a/tests/lib/mocha-3.1.0/lib/interfaces/index.js b/tests/lib/mocha-3.1.2/lib/interfaces/index.js index 4f825d15b2..0bd810abb7 100755..100644 --- a/tests/lib/mocha-3.1.0/lib/interfaces/index.js +++ b/tests/lib/mocha-3.1.2/lib/interfaces/index.js @@ -1,3 +1,5 @@ +'use strict'; + exports.bdd = require('./bdd'); exports.tdd = require('./tdd'); exports.qunit = require('./qunit'); diff --git a/tests/lib/mocha-3.1.0/lib/interfaces/qunit.js b/tests/lib/mocha-3.1.2/lib/interfaces/qunit.js index 22e8080e2e..44491db926 100644 --- a/tests/lib/mocha-3.1.0/lib/interfaces/qunit.js +++ b/tests/lib/mocha-3.1.2/lib/interfaces/qunit.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -29,10 +31,10 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.before = common.before; @@ -44,7 +46,7 @@ module.exports = function(suite) { * Describe a "suite" with the given `title`. */ - context.suite = function(title) { + context.suite = function (title) { if (suites.length > 1) { suites.shift(); } @@ -59,7 +61,7 @@ module.exports = function(suite) { * Exclusive Suite. */ - context.suite.only = function(title) { + context.suite.only = function (title) { if (suites.length > 1) { suites.shift(); } @@ -76,7 +78,7 @@ module.exports = function(suite) { * acting as a thunk. */ - context.test = function(title, fn) { + context.test = function (title, fn) { var test = new Test(title, fn); test.file = file; suites[0].addTest(test); @@ -87,7 +89,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.test.only = function(title, fn) { + context.test.only = function (title, fn) { return common.test.only(mocha, context.test(title, fn)); }; diff --git a/tests/lib/mocha-3.1.0/lib/interfaces/tdd.js b/tests/lib/mocha-3.1.2/lib/interfaces/tdd.js index 445e992213..253e221575 100644 --- a/tests/lib/mocha-3.1.0/lib/interfaces/tdd.js +++ b/tests/lib/mocha-3.1.2/lib/interfaces/tdd.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -29,10 +31,10 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.setup = common.beforeEach; @@ -45,7 +47,7 @@ module.exports = function(suite) { * Describe a "suite" with the given `title` and callback `fn` containing * nested suites and/or tests. */ - context.suite = function(title, fn) { + context.suite = function (title, fn) { return common.suite.create({ title: title, file: file, @@ -56,7 +58,7 @@ module.exports = function(suite) { /** * Pending suite. */ - context.suite.skip = function(title, fn) { + context.suite.skip = function (title, fn) { return common.suite.skip({ title: title, file: file, @@ -67,7 +69,7 @@ module.exports = function(suite) { /** * Exclusive test-case. */ - context.suite.only = function(title, fn) { + context.suite.only = function (title, fn) { return common.suite.only({ title: title, file: file, @@ -79,7 +81,7 @@ module.exports = function(suite) { * Describe a specification or test-case with the given `title` and * callback `fn` acting as a thunk. */ - context.test = function(title, fn) { + context.test = function (title, fn) { var suite = suites[0]; if (suite.isPending()) { fn = null; @@ -94,7 +96,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.test.only = function(title, fn) { + context.test.only = function (title, fn) { return common.test.only(mocha, context.test(title, fn)); }; diff --git a/tests/lib/mocha-3.1.0/lib/mocha.js b/tests/lib/mocha-3.1.2/lib/mocha.js index a649715191..dcc1492f5a 100644 --- a/tests/lib/mocha-3.1.0/lib/mocha.js +++ b/tests/lib/mocha-3.1.2/lib/mocha.js @@ -1,3 +1,5 @@ +'use strict'; + /*! * mocha * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca> @@ -49,7 +51,7 @@ exports.Test = require('./test'); * @param {string} name * @return {string} */ -function image(name) { +function image (name) { return path.join(__dirname, '../images', name + '.png'); } @@ -72,7 +74,7 @@ function image(name) { * @param {Object} options * @api public */ -function Mocha(options) { +function Mocha (options) { options = options || {}; this.files = []; this.options = options; @@ -107,7 +109,7 @@ function Mocha(options) { * @api public * @param {boolean} [bail] */ -Mocha.prototype.bail = function(bail) { +Mocha.prototype.bail = function (bail) { if (!arguments.length) { bail = true; } @@ -121,7 +123,7 @@ Mocha.prototype.bail = function(bail) { * @api public * @param {string} file */ -Mocha.prototype.addFile = function(file) { +Mocha.prototype.addFile = function (file) { this.files.push(file); return this; }; @@ -135,7 +137,7 @@ Mocha.prototype.addFile = function(file) { * @param {string|Function} reporter name or constructor * @param {Object} reporterOptions optional options */ -Mocha.prototype.reporter = function(reporter, reporterOptions) { +Mocha.prototype.reporter = function (reporter, reporterOptions) { if (typeof reporter === 'function') { this._reporter = reporter; } else { @@ -156,9 +158,9 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) { } } if (!_reporter && reporter === 'teamcity') { - console.warn('The Teamcity reporter was moved to a package named ' - + 'mocha-teamcity-reporter ' - + '(https://npmjs.org/package/mocha-teamcity-reporter).'); + console.warn('The Teamcity reporter was moved to a package named ' + + 'mocha-teamcity-reporter ' + + '(https://npmjs.org/package/mocha-teamcity-reporter).'); } if (!_reporter) { throw new Error('invalid reporter "' + reporter + '"'); @@ -175,7 +177,7 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) { * @api public * @param {string} bdd */ -Mocha.prototype.ui = function(name) { +Mocha.prototype.ui = function (name) { name = name || 'bdd'; this._ui = exports.interfaces[name]; if (!this._ui) { @@ -187,7 +189,7 @@ Mocha.prototype.ui = function(name) { } this._ui = this._ui(this.suite); - this.suite.on('pre-require', function(context) { + this.suite.on('pre-require', function (context) { exports.afterEach = context.afterEach || context.teardown; exports.after = context.after || context.suiteTeardown; exports.beforeEach = context.beforeEach || context.setup; @@ -211,10 +213,10 @@ Mocha.prototype.ui = function(name) { * * @api private */ -Mocha.prototype.loadFiles = function(fn) { +Mocha.prototype.loadFiles = function (fn) { var self = this; var suite = this.suite; - this.files.forEach(function(file) { + this.files.forEach(function (file) { file = path.resolve(file); suite.emit('pre-require', global, file, self); suite.emit('require', require(file), file, self); @@ -228,10 +230,10 @@ Mocha.prototype.loadFiles = function(fn) { * * @api private */ -Mocha.prototype._growl = function(runner, reporter) { +Mocha.prototype._growl = function (runner, reporter) { var notify = require('growl'); - runner.on('end', function() { + runner.on('end', function () { var stats = reporter.stats; if (stats.failures) { var msg = stats.failures + ' of ' + runner.total + ' tests failed'; @@ -253,7 +255,7 @@ Mocha.prototype._growl = function(runner, reporter) { * @param str * @returns {Mocha} */ -Mocha.prototype.fgrep = function(str) { +Mocha.prototype.fgrep = function (str) { return this.grep(new RegExp(escapeRe(str))); }; @@ -266,7 +268,7 @@ Mocha.prototype.fgrep = function(str) { * @param {RegExp|string} re * @return {Mocha} */ -Mocha.prototype.grep = function(re) { +Mocha.prototype.grep = function (re) { if (utils.isString(re)) { // extract args if it's regex-like, i.e: [string, pattern, flag] var arg = re.match(/^\/(.*)\/(g|i|)$|.*/); @@ -282,7 +284,7 @@ Mocha.prototype.grep = function(re) { * @return {Mocha} * @api public */ -Mocha.prototype.invert = function() { +Mocha.prototype.invert = function () { this.options.invert = true; return this; }; @@ -296,7 +298,7 @@ Mocha.prototype.invert = function() { * @param {boolean} ignore * @return {Mocha} */ -Mocha.prototype.ignoreLeaks = function(ignore) { +Mocha.prototype.ignoreLeaks = function (ignore) { this.options.ignoreLeaks = Boolean(ignore); return this; }; @@ -307,7 +309,7 @@ Mocha.prototype.ignoreLeaks = function(ignore) { * @return {Mocha} * @api public */ -Mocha.prototype.checkLeaks = function() { +Mocha.prototype.checkLeaks = function () { this.options.ignoreLeaks = false; return this; }; @@ -318,7 +320,7 @@ Mocha.prototype.checkLeaks = function() { * @return {Mocha} * @api public */ -Mocha.prototype.fullTrace = function() { +Mocha.prototype.fullTrace = function () { this.options.fullStackTrace = true; return this; }; @@ -329,7 +331,7 @@ Mocha.prototype.fullTrace = function() { * @return {Mocha} * @api public */ -Mocha.prototype.growl = function() { +Mocha.prototype.growl = function () { this.options.growl = true; return this; }; @@ -343,7 +345,7 @@ Mocha.prototype.growl = function() { * @param {Array|string} globals * @return {Mocha} */ -Mocha.prototype.globals = function(globals) { +Mocha.prototype.globals = function (globals) { this.options.globals = (this.options.globals || []).concat(globals); return this; }; @@ -357,7 +359,7 @@ Mocha.prototype.globals = function(globals) { * @param {boolean} colors * @return {Mocha} */ -Mocha.prototype.useColors = function(colors) { +Mocha.prototype.useColors = function (colors) { if (colors !== undefined) { this.options.useColors = colors; } @@ -373,7 +375,7 @@ Mocha.prototype.useColors = function(colors) { * @param {boolean} inlineDiffs * @return {Mocha} */ -Mocha.prototype.useInlineDiffs = function(inlineDiffs) { +Mocha.prototype.useInlineDiffs = function (inlineDiffs) { this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs; return this; }; @@ -387,7 +389,7 @@ Mocha.prototype.useInlineDiffs = function(inlineDiffs) { * @param {number} timeout * @return {Mocha} */ -Mocha.prototype.timeout = function(timeout) { +Mocha.prototype.timeout = function (timeout) { this.suite.timeout(timeout); return this; }; @@ -399,7 +401,7 @@ Mocha.prototype.timeout = function(timeout) { * @return {Mocha} * @api public */ -Mocha.prototype.retries = function(n) { +Mocha.prototype.retries = function (n) { this.suite.retries(n); return this; }; @@ -413,7 +415,7 @@ Mocha.prototype.retries = function(n) { * @param {number} slow * @return {Mocha} */ -Mocha.prototype.slow = function(slow) { +Mocha.prototype.slow = function (slow) { this.suite.slow(slow); return this; }; @@ -427,7 +429,7 @@ Mocha.prototype.slow = function(slow) { * @param {boolean} enabled * @return {Mocha} */ -Mocha.prototype.enableTimeouts = function(enabled) { +Mocha.prototype.enableTimeouts = function (enabled) { this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true); return this; }; @@ -438,7 +440,7 @@ Mocha.prototype.enableTimeouts = function(enabled) { * @return {Mocha} * @api public */ -Mocha.prototype.asyncOnly = function() { +Mocha.prototype.asyncOnly = function () { this.options.asyncOnly = true; return this; }; @@ -448,7 +450,7 @@ Mocha.prototype.asyncOnly = function() { * * @api public */ -Mocha.prototype.noHighlighting = function() { +Mocha.prototype.noHighlighting = function () { this.options.noHighlighting = true; return this; }; @@ -459,7 +461,7 @@ Mocha.prototype.noHighlighting = function() { * @return {Mocha} * @api public */ -Mocha.prototype.allowUncaught = function() { +Mocha.prototype.allowUncaught = function () { this.options.allowUncaught = true; return this; }; @@ -468,7 +470,7 @@ Mocha.prototype.allowUncaught = function() { * Delay root suite execution. * @returns {Mocha} */ -Mocha.prototype.delay = function delay() { +Mocha.prototype.delay = function delay () { this.options.delay = true; return this; }; @@ -480,7 +482,7 @@ Mocha.prototype.delay = function delay() { * @param {Function} fn * @return {Runner} */ -Mocha.prototype.run = function(fn) { +Mocha.prototype.run = function (fn) { if (this.files.length) { this.loadFiles(); } @@ -508,7 +510,7 @@ Mocha.prototype.run = function(fn) { } exports.reporters.Base.inlineDiffs = options.useInlineDiffs; - function done(failures) { + function done (failures) { if (reporter.done) { reporter.done(failures, fn); } else { diff --git a/tests/lib/mocha-3.1.0/lib/ms.js b/tests/lib/mocha-3.1.2/lib/ms.js index 12fddc18ae..9590856052 100644 --- a/tests/lib/mocha-3.1.0/lib/ms.js +++ b/tests/lib/mocha-3.1.2/lib/ms.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Helpers. */ @@ -20,7 +22,7 @@ var y = d * 365.25; * @param {Object} options * @return {string|number} */ -module.exports = function(val, options) { +module.exports = function (val, options) { options = options || {}; if (typeof val === 'string') { return parse(val); @@ -36,7 +38,7 @@ module.exports = function(val, options) { * @param {string} str * @return {number} */ -function parse(str) { +function parse (str) { var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str); if (!match) { return; @@ -78,7 +80,7 @@ function parse(str) { * @param {number} ms * @return {string} */ -function shortFormat(ms) { +function shortFormat (ms) { if (ms >= d) { return Math.round(ms / d) + 'd'; } @@ -101,12 +103,12 @@ function shortFormat(ms) { * @param {number} ms * @return {string} */ -function longFormat(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; +function longFormat (ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms'; } /** @@ -117,7 +119,7 @@ function longFormat(ms) { * @param {number} n * @param {string} name */ -function plural(ms, n, name) { +function plural (ms, n, name) { if (ms < n) { return; } diff --git a/tests/lib/mocha-3.1.0/lib/pending.js b/tests/lib/mocha-3.1.2/lib/pending.js index c847e04e3f..c780104610 100644 --- a/tests/lib/mocha-3.1.0/lib/pending.js +++ b/tests/lib/mocha-3.1.2/lib/pending.js @@ -1,3 +1,4 @@ +'use strict'; /** * Expose `Pending`. @@ -10,6 +11,6 @@ module.exports = Pending; * * @param {string} message */ -function Pending(message) { +function Pending (message) { this.message = message; } diff --git a/tests/lib/mocha-3.1.0/lib/reporters/base.js b/tests/lib/mocha-3.1.2/lib/reporters/base.js index c754c5231f..205488426a 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/base.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/base.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -101,7 +103,7 @@ if (process.platform === 'win32') { * @return {string} * @api private */ -var color = exports.color = function(type, str) { +var color = exports.color = function (type, str) { if (!exports.useColors) { return String(str); } @@ -127,23 +129,23 @@ if (isatty) { */ exports.cursor = { - hide: function() { + hide: function () { isatty && process.stdout.write('\u001b[?25l'); }, - show: function() { + show: function () { isatty && process.stdout.write('\u001b[?25h'); }, - deleteLine: function() { + deleteLine: function () { isatty && process.stdout.write('\u001b[2K'); }, - beginningOfLine: function() { + beginningOfLine: function () { isatty && process.stdout.write('\u001b[0G'); }, - CR: function() { + CR: function () { if (isatty) { exports.cursor.deleteLine(); exports.cursor.beginningOfLine(); @@ -160,13 +162,13 @@ exports.cursor = { * @api public */ -exports.list = function(failures) { +exports.list = function (failures) { console.log(); - failures.forEach(function(test, i) { + failures.forEach(function (test, i) { // format - var fmt = color('error title', ' %s) %s:\n') - + color('error message', ' %s') - + color('error stack', '\n%s\n'); + var fmt = color('error title', ' %s) %s:\n') + + color('error message', ' %s') + + color('error stack', '\n%s\n'); // msg var msg; @@ -236,7 +238,7 @@ exports.list = function(failures) { * @api public */ -function Base(runner) { +function Base (runner) { var stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }; var failures = this.failures = []; @@ -247,21 +249,21 @@ function Base(runner) { runner.stats = stats; - runner.on('start', function() { + runner.on('start', function () { stats.start = new Date(); }); - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { stats.suites = stats.suites || 0; suite.root || stats.suites++; }); - runner.on('test end', function() { + runner.on('test end', function () { stats.tests = stats.tests || 0; stats.tests++; }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { stats.passes = stats.passes || 0; if (test.duration > test.slow()) { @@ -275,19 +277,19 @@ function Base(runner) { stats.passes++; }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { stats.failures = stats.failures || 0; stats.failures++; test.err = err; failures.push(test); }); - runner.on('end', function() { + runner.on('end', function () { stats.end = new Date(); stats.duration = new Date() - stats.start; }); - runner.on('pending', function() { + runner.on('pending', function () { stats.pending++; }); } @@ -298,16 +300,16 @@ function Base(runner) { * * @api public */ -Base.prototype.epilogue = function() { +Base.prototype.epilogue = function () { var stats = this.stats; var fmt; console.log(); // passes - fmt = color('bright pass', ' ') - + color('green', ' %d passing') - + color('light', ' (%s)'); + fmt = color('bright pass', ' ') + + color('green', ' %d passing') + + color('light', ' (%s)'); console.log(fmt, stats.passes || 0, @@ -315,8 +317,8 @@ Base.prototype.epilogue = function() { // pending if (stats.pending) { - fmt = color('pending', ' ') - + color('pending', ' %d pending'); + fmt = color('pending', ' ') + + color('pending', ' %d pending'); console.log(fmt, stats.pending); } @@ -342,7 +344,7 @@ Base.prototype.epilogue = function() { * @param {string} len * @return {string} */ -function pad(str, len) { +function pad (str, len) { str = String(str); return Array(len - str.length + 1).join(' ') + str; } @@ -355,26 +357,26 @@ function pad(str, len) { * @param {boolean} escape * @return {string} Diff */ -function inlineDiff(err, escape) { +function inlineDiff (err, escape) { var msg = errorDiff(err, 'WordsWithSpace', escape); // linenos var lines = msg.split('\n'); if (lines.length > 4) { var width = String(lines.length).length; - msg = lines.map(function(str, i) { + msg = lines.map(function (str, i) { return pad(++i, width) + ' |' + ' ' + str; }).join('\n'); } // legend - msg = '\n' - + color('diff removed', 'actual') - + ' ' - + color('diff added', 'expected') - + '\n\n' - + msg - + '\n'; + msg = '\n' + + color('diff removed', 'actual') + + ' ' + + color('diff added', 'expected') + + '\n\n' + + msg + + '\n'; // indent msg = msg.replace(/^/gm, ' '); @@ -389,9 +391,9 @@ function inlineDiff(err, escape) { * @param {boolean} escape * @return {string} The diff. */ -function unifiedDiff(err, escape) { +function unifiedDiff (err, escape) { var indent = ' '; - function cleanUp(line) { + function cleanUp (line) { if (escape) { line = escapeInvisibles(line); } @@ -401,7 +403,7 @@ function unifiedDiff(err, escape) { if (line[0] === '-') { return indent + colorLines('diff removed', line); } - if (line.match(/\@\@/)) { + if (line.match(/@@/)) { return null; } if (line.match(/\\ No newline/)) { @@ -409,16 +411,16 @@ function unifiedDiff(err, escape) { } return indent + line; } - function notBlank(line) { + function notBlank (line) { return typeof line !== 'undefined' && line !== null; } var msg = diff.createPatch('string', err.actual, err.expected); var lines = msg.split('\n').splice(4); - return '\n ' - + colorLines('diff added', '+ expected') + ' ' - + colorLines('diff removed', '- actual') - + '\n\n' - + lines.map(cleanUp).filter(notBlank).join('\n'); + return '\n ' + + colorLines('diff added', '+ expected') + ' ' + + colorLines('diff removed', '- actual') + + '\n\n' + + lines.map(cleanUp).filter(notBlank).join('\n'); } /** @@ -430,10 +432,10 @@ function unifiedDiff(err, escape) { * @param {boolean} escape * @return {string} */ -function errorDiff(err, type, escape) { +function errorDiff (err, type, escape) { var actual = escape ? escapeInvisibles(err.actual) : err.actual; var expected = escape ? escapeInvisibles(err.expected) : err.expected; - return diff['diff' + type](actual, expected).map(function(str) { + return diff['diff' + type](actual, expected).map(function (str) { if (str.added) { return colorLines('diff added', str.value); } @@ -451,7 +453,7 @@ function errorDiff(err, type, escape) { * @param {string} line * @return {string} */ -function escapeInvisibles(line) { +function escapeInvisibles (line) { return line.replace(/\t/g, '<tab>') .replace(/\r/g, '<CR>') .replace(/\n/g, '<LF>\n'); @@ -465,8 +467,8 @@ function escapeInvisibles(line) { * @param {string} str * @return {string} */ -function colorLines(name, str) { - return str.split('\n').map(function(str) { +function colorLines (name, str) { + return str.split('\n').map(function (str) { return color(name, str); }).join('\n'); } @@ -484,6 +486,6 @@ var objToString = Object.prototype.toString; * @param {Object} b * @return {boolean} */ -function sameType(a, b) { +function sameType (a, b) { return objToString.call(a) === objToString.call(b); } diff --git a/tests/lib/mocha-3.1.0/lib/reporters/doc.js b/tests/lib/mocha-3.1.2/lib/reporters/doc.js index 9f5c3f8a37..aad1d92522 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/doc.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/doc.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -17,16 +19,16 @@ exports = module.exports = Doc; * @param {Runner} runner * @api public */ -function Doc(runner) { +function Doc (runner) { Base.call(this, runner); var indents = 2; - function indent() { + function indent () { return Array(indents).join(' '); } - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { if (suite.root) { return; } @@ -37,7 +39,7 @@ function Doc(runner) { console.log('%s<dl>', indent()); }); - runner.on('suite end', function(suite) { + runner.on('suite end', function (suite) { if (suite.root) { return; } @@ -47,13 +49,13 @@ function Doc(runner) { --indents; }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title)); var code = utils.escape(utils.clean(test.body)); console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code); }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { console.log('%s <dt class="error">%s</dt>', indent(), utils.escape(test.title)); var code = utils.escape(utils.clean(test.body)); console.log('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(), code); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/dot.js b/tests/lib/mocha-3.1.2/lib/reporters/dot.js index f8b4b41fe0..81e106edd0 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/dot.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/dot.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -18,25 +20,25 @@ exports = module.exports = Dot; * @api public * @param {Runner} runner */ -function Dot(runner) { +function Dot (runner) { Base.call(this, runner); var self = this; - var width = Base.window.width * .75 | 0; + var width = Base.window.width * 0.75 | 0; var n = -1; - runner.on('start', function() { + runner.on('start', function () { process.stdout.write('\n'); }); - runner.on('pending', function() { + runner.on('pending', function () { if (++n % width === 0) { process.stdout.write('\n '); } process.stdout.write(color('pending', Base.symbols.comma)); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { if (++n % width === 0) { process.stdout.write('\n '); } @@ -47,14 +49,14 @@ function Dot(runner) { } }); - runner.on('fail', function() { + runner.on('fail', function () { if (++n % width === 0) { process.stdout.write('\n '); } process.stdout.write(color('fail', Base.symbols.bang)); }); - runner.on('end', function() { + runner.on('end', function () { console.log(); self.epilogue(); }); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/html.js b/tests/lib/mocha-3.1.2/lib/reporters/html.js index 51ba1ca722..9b9817c509 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/html.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/html.js @@ -1,3 +1,5 @@ +'use strict'; + /* eslint-env browser */ /** @@ -32,12 +34,12 @@ exports = module.exports = HTML; * Stats template. */ -var statsTemplate = '<ul id="mocha-stats">' - + '<li class="progress"><canvas width="40" height="40"></canvas></li>' - + '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' - + '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' - + '<li class="duration">duration: <em>0</em>s</li>' - + '</ul>'; +var statsTemplate = '<ul id="mocha-stats">' + + '<li class="progress"><canvas width="40" height="40"></canvas></li>' + + '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' + + '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' + + '<li class="duration">duration: <em>0</em>s</li>' + + '</ul>'; /** * Initialize a new `HTML` reporter. @@ -45,7 +47,7 @@ var statsTemplate = '<ul id="mocha-stats">' * @api public * @param {Runner} runner */ -function HTML(runner) { +function HTML (runner) { Base.call(this, runner); var self = this; @@ -80,7 +82,7 @@ function HTML(runner) { } // pass toggle - on(passesLink, 'click', function(evt) { + on(passesLink, 'click', function (evt) { evt.preventDefault(); unhide(); var name = (/pass/).test(report.className) ? '' : ' pass'; @@ -91,7 +93,7 @@ function HTML(runner) { }); // failure toggle - on(failuresLink, 'click', function(evt) { + on(failuresLink, 'click', function (evt) { evt.preventDefault(); unhide(); var name = (/fail/).test(report.className) ? '' : ' fail'; @@ -108,7 +110,7 @@ function HTML(runner) { progress.size(40); } - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { if (suite.root) { return; } @@ -123,7 +125,7 @@ function HTML(runner) { el.appendChild(stack[0]); }); - runner.on('suite end', function(suite) { + runner.on('suite end', function (suite) { if (suite.root) { updateStats(); return; @@ -131,17 +133,17 @@ function HTML(runner) { stack.shift(); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { var url = self.testURL(test); - var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' - + '<a href="%s" class="replay">‣</a></h2></li>'; + var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' + + '<a href="%s" class="replay">‣</a></h2></li>'; var el = fragment(markup, test.speed, test.title, test.duration, url); self.addCodeToggle(el, test.body); appendToStack(el); updateStats(); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">‣</a></h2></li>', test.title, self.testURL(test)); var stackString; // Note: Includes leading newline @@ -181,20 +183,20 @@ function HTML(runner) { updateStats(); }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title); appendToStack(el); updateStats(); }); - function appendToStack(el) { + function appendToStack (el) { // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack. if (stack[0]) { stack[0].appendChild(el); } } - function updateStats() { + function updateStats () { // TODO: add to stats var percent = stats.tests / runner.total * 100 | 0; if (progress) { @@ -215,7 +217,7 @@ function HTML(runner) { * @param {string} s * @return {string} A new URL. */ -function makeUrl(s) { +function makeUrl (s) { var search = window.location.search; // Remove previous grep query parameter if present @@ -231,7 +233,7 @@ function makeUrl(s) { * * @param {Object} [suite] */ -HTML.prototype.suiteURL = function(suite) { +HTML.prototype.suiteURL = function (suite) { return makeUrl(suite.fullTitle()); }; @@ -240,7 +242,7 @@ HTML.prototype.suiteURL = function(suite) { * * @param {Object} [test] */ -HTML.prototype.testURL = function(test) { +HTML.prototype.testURL = function (test) { return makeUrl(test.fullTitle()); }; @@ -250,10 +252,10 @@ HTML.prototype.testURL = function(test) { * @param {HTMLLIElement} el * @param {string} contents */ -HTML.prototype.addCodeToggle = function(el, contents) { +HTML.prototype.addCodeToggle = function (el, contents) { var h2 = el.getElementsByTagName('h2')[0]; - on(h2, 'click', function() { + on(h2, 'click', function () { pre.style.display = pre.style.display === 'none' ? 'block' : 'none'; }); @@ -267,7 +269,7 @@ HTML.prototype.addCodeToggle = function(el, contents) { * * @param {string} msg */ -function error(msg) { +function error (msg) { document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg)); } @@ -276,12 +278,12 @@ function error(msg) { * * @param {string} html */ -function fragment(html) { +function fragment (html) { var args = arguments; var div = document.createElement('div'); var i = 1; - div.innerHTML = html.replace(/%([se])/g, function(_, type) { + div.innerHTML = html.replace(/%([se])/g, function (_, type) { switch (type) { case 's': return String(args[i++]); case 'e': return escape(args[i++]); @@ -298,7 +300,7 @@ function fragment(html) { * * @param {text} classname */ -function hideSuitesWithout(classname) { +function hideSuitesWithout (classname) { var suites = document.getElementsByClassName('suite'); for (var i = 0; i < suites.length; i++) { var els = suites[i].getElementsByClassName(classname); @@ -311,7 +313,7 @@ function hideSuitesWithout(classname) { /** * Unhide .hidden suites. */ -function unhide() { +function unhide () { var els = document.getElementsByClassName('suite hidden'); for (var i = 0; i < els.length; ++i) { els[i].className = els[i].className.replace('suite hidden', 'suite'); @@ -324,7 +326,7 @@ function unhide() { * @param {HTMLElement} el * @param {string} contents */ -function text(el, contents) { +function text (el, contents) { if (el.textContent) { el.textContent = contents; } else { @@ -335,7 +337,7 @@ function text(el, contents) { /** * Listen on `event` with callback `fn`. */ -function on(el, event, fn) { +function on (el, event, fn) { if (el.addEventListener) { el.addEventListener(event, fn, false); } else { diff --git a/tests/lib/mocha-3.1.0/lib/reporters/index.js b/tests/lib/mocha-3.1.2/lib/reporters/index.js index 221a81d95b..d3b5481e41 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/index.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/index.js @@ -1,3 +1,5 @@ +'use strict'; + // Alias exports to a their normalized format Mocha#reporter to prevent a need // for dynamic (try/catch) requires, which Browserify doesn't handle. exports.Base = exports.base = require('./base'); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/json-stream.js b/tests/lib/mocha-3.1.2/lib/reporters/json-stream.js index f07f8657c0..6126e47ea1 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/json-stream.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/json-stream.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -17,28 +19,28 @@ exports = module.exports = List; * @api public * @param {Runner} runner */ -function List(runner) { +function List (runner) { Base.call(this, runner); var self = this; var total = runner.total; - runner.on('start', function() { + runner.on('start', function () { console.log(JSON.stringify(['start', { total: total }])); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { console.log(JSON.stringify(['pass', clean(test)])); }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { test = clean(test); test.err = err.message; test.stack = err.stack || null; console.log(JSON.stringify(['fail', test])); }); - runner.on('end', function() { + runner.on('end', function () { process.stdout.write(JSON.stringify(['end', self.stats])); }); } @@ -51,7 +53,7 @@ function List(runner) { * @param {Object} test * @return {Object} */ -function clean(test) { +function clean (test) { return { title: test.title, fullTitle: test.fullTitle(), diff --git a/tests/lib/mocha-3.1.0/lib/reporters/json.js b/tests/lib/mocha-3.1.2/lib/reporters/json.js index cd9ec286b7..259a782121 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/json.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/json.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -16,7 +18,7 @@ exports = module.exports = JSONReporter; * @api public * @param {Runner} runner */ -function JSONReporter(runner) { +function JSONReporter (runner) { Base.call(this, runner); var self = this; @@ -25,23 +27,23 @@ function JSONReporter(runner) { var failures = []; var passes = []; - runner.on('test end', function(test) { + runner.on('test end', function (test) { tests.push(test); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { passes.push(test); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { failures.push(test); }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { pending.push(test); }); - runner.on('end', function() { + runner.on('end', function () { var obj = { stats: self.stats, tests: tests.map(clean), @@ -64,7 +66,7 @@ function JSONReporter(runner) { * @param {Object} test * @return {Object} */ -function clean(test) { +function clean (test) { return { title: test.title, fullTitle: test.fullTitle(), @@ -81,9 +83,9 @@ function clean(test) { * @param {Error} err * @return {Object} */ -function errorJSON(err) { +function errorJSON (err) { var res = {}; - Object.getOwnPropertyNames(err).forEach(function(key) { + Object.getOwnPropertyNames(err).forEach(function (key) { res[key] = err[key]; }, err); return res; diff --git a/tests/lib/mocha-3.1.0/lib/reporters/landing.js b/tests/lib/mocha-3.1.2/lib/reporters/landing.js index b66b2000c1..b8c7b5f20c 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/landing.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/landing.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -37,28 +39,28 @@ Base.colors.runway = 90; * @api public * @param {Runner} runner */ -function Landing(runner) { +function Landing (runner) { Base.call(this, runner); var self = this; - var width = Base.window.width * .75 | 0; + var width = Base.window.width * 0.75 | 0; var total = runner.total; var stream = process.stdout; var plane = color('plane', '✈'); var crashed = -1; var n = 0; - function runway() { + function runway () { var buf = Array(width).join('-'); return ' ' + color('runway', buf); } - runner.on('start', function() { + runner.on('start', function () { stream.write('\n\n\n '); cursor.hide(); }); - runner.on('test end', function(test) { + runner.on('test end', function (test) { // check if the plane crashed var col = crashed === -1 ? width * ++n / total | 0 : crashed; @@ -79,7 +81,7 @@ function Landing(runner) { stream.write('\u001b[0m'); }); - runner.on('end', function() { + runner.on('end', function () { cursor.show(); console.log(); self.epilogue(); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/list.js b/tests/lib/mocha-3.1.2/lib/reporters/list.js index 0e5f910d1f..2e54314e91 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/list.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/list.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -19,35 +21,35 @@ exports = module.exports = List; * @api public * @param {Runner} runner */ -function List(runner) { +function List (runner) { Base.call(this, runner); var self = this; var n = 0; - runner.on('start', function() { + runner.on('start', function () { console.log(); }); - runner.on('test', function(test) { + runner.on('test', function (test) { process.stdout.write(color('pass', ' ' + test.fullTitle() + ': ')); }); - runner.on('pending', function(test) { - var fmt = color('checkmark', ' -') - + color('pending', ' %s'); + runner.on('pending', function (test) { + var fmt = color('checkmark', ' -') + + color('pending', ' %s'); console.log(fmt, test.fullTitle()); }); - runner.on('pass', function(test) { - var fmt = color('checkmark', ' ' + Base.symbols.dot) - + color('pass', ' %s: ') - + color(test.speed, '%dms'); + runner.on('pass', function (test) { + var fmt = color('checkmark', ' ' + Base.symbols.dot) + + color('pass', ' %s: ') + + color(test.speed, '%dms'); cursor.CR(); console.log(fmt, test.fullTitle(), test.duration); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { cursor.CR(); console.log(color('fail', ' %d) %s'), ++n, test.fullTitle()); }); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/markdown.js b/tests/lib/mocha-3.1.2/lib/reporters/markdown.js index 680c55d709..9c06616ea9 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/markdown.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/markdown.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -23,29 +25,29 @@ exports = module.exports = Markdown; * @api public * @param {Runner} runner */ -function Markdown(runner) { +function Markdown (runner) { Base.call(this, runner); var level = 0; var buf = ''; - function title(str) { + function title (str) { return Array(level).join('#') + ' ' + str; } - function mapTOC(suite, obj) { + function mapTOC (suite, obj) { var ret = obj; var key = SUITE_PREFIX + suite.title; obj = obj[key] = obj[key] || { suite: suite }; - suite.suites.forEach(function(suite) { + suite.suites.forEach(function (suite) { mapTOC(suite, obj); }); return ret; } - function stringifyTOC(obj, level) { + function stringifyTOC (obj, level) { ++level; var buf = ''; var link; @@ -63,25 +65,25 @@ function Markdown(runner) { return buf; } - function generateTOC(suite) { + function generateTOC (suite) { var obj = mapTOC(suite, {}); return stringifyTOC(obj, 0); } generateTOC(runner.suite); - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { ++level; var slug = utils.slug(suite.fullTitle()); buf += '<a name="' + slug + '"></a>' + '\n'; buf += title(suite.title) + '\n'; }); - runner.on('suite end', function() { + runner.on('suite end', function () { --level; }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { var code = utils.clean(test.body); buf += test.title + '.\n'; buf += '\n```js\n'; @@ -89,7 +91,7 @@ function Markdown(runner) { buf += '```\n\n'; }); - runner.on('end', function() { + runner.on('end', function () { process.stdout.write('# TOC\n'); process.stdout.write(generateTOC(runner.suite)); process.stdout.write(buf); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/min.js b/tests/lib/mocha-3.1.2/lib/reporters/min.js index 2b48212ca8..0d772f9601 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/min.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/min.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -17,10 +19,10 @@ exports = module.exports = Min; * @api public * @param {Runner} runner */ -function Min(runner) { +function Min (runner) { Base.call(this, runner); - runner.on('start', function() { + runner.on('start', function () { // clear screen process.stdout.write('\u001b[2J'); // set cursor position diff --git a/tests/lib/mocha-3.1.0/lib/reporters/nyan.js b/tests/lib/mocha-3.1.2/lib/reporters/nyan.js index ba1b0509d9..1be49a97b9 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/nyan.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/nyan.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -18,11 +20,11 @@ exports = module.exports = NyanCat; * @api public */ -function NyanCat(runner) { +function NyanCat (runner) { Base.call(this, runner); var self = this; - var width = Base.window.width * .75 | 0; + var width = Base.window.width * 0.75 | 0; var nyanCatWidth = this.nyanCatWidth = 11; this.colorIndex = 0; @@ -33,24 +35,24 @@ function NyanCat(runner) { this.trajectories = [[], [], [], []]; this.trajectoryWidthMax = (width - nyanCatWidth); - runner.on('start', function() { + runner.on('start', function () { Base.cursor.hide(); self.draw(); }); - runner.on('pending', function() { + runner.on('pending', function () { self.draw(); }); - runner.on('pass', function() { + runner.on('pass', function () { self.draw(); }); - runner.on('fail', function() { + runner.on('fail', function () { self.draw(); }); - runner.on('end', function() { + runner.on('end', function () { Base.cursor.show(); for (var i = 0; i < self.numberOfLines; i++) { write('\n'); @@ -70,7 +72,7 @@ inherits(NyanCat, Base); * @api private */ -NyanCat.prototype.draw = function() { +NyanCat.prototype.draw = function () { this.appendRainbow(); this.drawScoreboard(); this.drawRainbow(); @@ -85,10 +87,10 @@ NyanCat.prototype.draw = function() { * @api private */ -NyanCat.prototype.drawScoreboard = function() { +NyanCat.prototype.drawScoreboard = function () { var stats = this.stats; - function draw(type, n) { + function draw (type, n) { write(' '); write(Base.color(type, n)); write('\n'); @@ -108,7 +110,7 @@ NyanCat.prototype.drawScoreboard = function() { * @api private */ -NyanCat.prototype.appendRainbow = function() { +NyanCat.prototype.appendRainbow = function () { var segment = this.tick ? '_' : '-'; var rainbowified = this.rainbowify(segment); @@ -127,10 +129,10 @@ NyanCat.prototype.appendRainbow = function() { * @api private */ -NyanCat.prototype.drawRainbow = function() { +NyanCat.prototype.drawRainbow = function () { var self = this; - this.trajectories.forEach(function(line) { + this.trajectories.forEach(function (line) { write('\u001b[' + self.scoreboardWidth + 'C'); write(line.join('')); write('\n'); @@ -144,7 +146,7 @@ NyanCat.prototype.drawRainbow = function() { * * @api private */ -NyanCat.prototype.drawNyanCat = function() { +NyanCat.prototype.drawNyanCat = function () { var self = this; var startWidth = this.scoreboardWidth + this.trajectories[0].length; var dist = '\u001b[' + startWidth + 'C'; @@ -180,7 +182,7 @@ NyanCat.prototype.drawNyanCat = function() { * @return {string} */ -NyanCat.prototype.face = function() { +NyanCat.prototype.face = function () { var stats = this.stats; if (stats.failures) { return '( x .x)'; @@ -199,7 +201,7 @@ NyanCat.prototype.face = function() { * @param {number} n */ -NyanCat.prototype.cursorUp = function(n) { +NyanCat.prototype.cursorUp = function (n) { write('\u001b[' + n + 'A'); }; @@ -210,7 +212,7 @@ NyanCat.prototype.cursorUp = function(n) { * @param {number} n */ -NyanCat.prototype.cursorDown = function(n) { +NyanCat.prototype.cursorDown = function (n) { write('\u001b[' + n + 'B'); }; @@ -220,7 +222,7 @@ NyanCat.prototype.cursorDown = function(n) { * @api private * @return {Array} */ -NyanCat.prototype.generateColors = function() { +NyanCat.prototype.generateColors = function () { var colors = []; for (var i = 0; i < (6 * 7); i++) { @@ -242,7 +244,7 @@ NyanCat.prototype.generateColors = function() { * @param {string} str * @return {string} */ -NyanCat.prototype.rainbowify = function(str) { +NyanCat.prototype.rainbowify = function (str) { if (!Base.useColors) { return str; } @@ -256,6 +258,6 @@ NyanCat.prototype.rainbowify = function(str) { * * @param {string} string A message to write to stdout. */ -function write(string) { +function write (string) { process.stdout.write(string); } diff --git a/tests/lib/mocha-3.1.0/lib/reporters/progress.js b/tests/lib/mocha-3.1.2/lib/reporters/progress.js index 5349ca8936..378ce38272 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/progress.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/progress.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -26,11 +28,11 @@ Base.colors.progress = 90; * @param {Runner} runner * @param {Object} options */ -function Progress(runner, options) { +function Progress (runner, options) { Base.call(this, runner); var self = this; - var width = Base.window.width * .50 | 0; + var width = Base.window.width * 0.50 | 0; var total = runner.total; var complete = 0; var lastN = -1; @@ -44,13 +46,13 @@ function Progress(runner, options) { options.verbose = false; // tests started - runner.on('start', function() { + runner.on('start', function () { console.log(); cursor.hide(); }); // tests complete - runner.on('test end', function() { + runner.on('test end', function () { complete++; var percent = complete / total; @@ -76,7 +78,7 @@ function Progress(runner, options) { // tests are complete, output some stats // and the failures if any - runner.on('end', function() { + runner.on('end', function () { cursor.show(); console.log(); self.epilogue(); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/spec.js b/tests/lib/mocha-3.1.2/lib/reporters/spec.js index 28993a8f32..993aff8dd3 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/spec.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/spec.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -18,55 +20,55 @@ exports = module.exports = Spec; * @api public * @param {Runner} runner */ -function Spec(runner) { +function Spec (runner) { Base.call(this, runner); var self = this; var indents = 0; var n = 0; - function indent() { + function indent () { return Array(indents).join(' '); } - runner.on('start', function() { + runner.on('start', function () { console.log(); }); - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { ++indents; console.log(color('suite', '%s%s'), indent(), suite.title); }); - runner.on('suite end', function() { + runner.on('suite end', function () { --indents; if (indents === 1) { console.log(); } }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { var fmt = indent() + color('pending', ' - %s'); console.log(fmt, test.title); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { var fmt; if (test.speed === 'fast') { - fmt = indent() - + color('checkmark', ' ' + Base.symbols.ok) - + color('pass', ' %s'); + fmt = indent() + + color('checkmark', ' ' + Base.symbols.ok) + + color('pass', ' %s'); console.log(fmt, test.title); } else { - fmt = indent() - + color('checkmark', ' ' + Base.symbols.ok) - + color('pass', ' %s') - + color(test.speed, ' (%dms)'); + fmt = indent() + + color('checkmark', ' ' + Base.symbols.ok) + + color('pass', ' %s') + + color(test.speed, ' (%dms)'); console.log(fmt, test.title, test.duration); } }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { console.log(indent() + color('fail', ' %d) %s'), ++n, test.title); }); diff --git a/tests/lib/mocha-3.1.0/lib/reporters/tap.js b/tests/lib/mocha-3.1.2/lib/reporters/tap.js index d9b1b953aa..e37ac1b16f 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/tap.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/tap.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -16,32 +18,32 @@ exports = module.exports = TAP; * @api public * @param {Runner} runner */ -function TAP(runner) { +function TAP (runner) { Base.call(this, runner); var n = 1; var passes = 0; var failures = 0; - runner.on('start', function() { + runner.on('start', function () { var total = runner.grepTotal(runner.suite); console.log('%d..%d', 1, total); }); - runner.on('test end', function() { + runner.on('test end', function () { ++n; }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { console.log('ok %d %s # SKIP -', n, title(test)); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { passes++; console.log('ok %d %s', n, title(test)); }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { failures++; console.log('not ok %d %s', n, title(test)); if (err.stack) { @@ -49,7 +51,7 @@ function TAP(runner) { } }); - runner.on('end', function() { + runner.on('end', function () { console.log('# tests ' + (passes + failures)); console.log('# pass ' + passes); console.log('# fail ' + failures); @@ -63,6 +65,6 @@ function TAP(runner) { * @param {Object} test * @return {String} */ -function title(test) { +function title (test) { return test.fullTitle().replace(/#/g, ''); } diff --git a/tests/lib/mocha-3.1.0/lib/reporters/xunit.js b/tests/lib/mocha-3.1.2/lib/reporters/xunit.js index 1cfd8f4f51..08f7b4cac3 100644 --- a/tests/lib/mocha-3.1.0/lib/reporters/xunit.js +++ b/tests/lib/mocha-3.1.2/lib/reporters/xunit.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -34,7 +36,7 @@ exports = module.exports = XUnit; * @api public * @param {Runner} runner */ -function XUnit(runner, options) { +function XUnit (runner, options) { Base.call(this, runner); var stats = this.stats; @@ -49,19 +51,19 @@ function XUnit(runner, options) { self.fileStream = fs.createWriteStream(options.reporterOptions.output); } - runner.on('pending', function(test) { + runner.on('pending', function (test) { tests.push(test); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { tests.push(test); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { tests.push(test); }); - runner.on('end', function() { + runner.on('end', function () { self.write(tag('testsuite', { name: 'Mocha Tests', tests: stats.tests, @@ -72,7 +74,7 @@ function XUnit(runner, options) { time: (stats.duration / 1000) || 0 }, false)); - tests.forEach(function(t) { + tests.forEach(function (t) { self.test(t); }); @@ -91,9 +93,9 @@ inherits(XUnit, Base); * @param failures * @param {Function} fn */ -XUnit.prototype.done = function(failures, fn) { +XUnit.prototype.done = function (failures, fn) { if (this.fileStream) { - this.fileStream.end(function() { + this.fileStream.end(function () { fn(failures); }); } else { @@ -106,7 +108,7 @@ XUnit.prototype.done = function(failures, fn) { * * @param {string} line */ -XUnit.prototype.write = function(line) { +XUnit.prototype.write = function (line) { if (this.fileStream) { this.fileStream.write(line + '\n'); } else if (typeof process === 'object' && process.stdout) { @@ -121,7 +123,7 @@ XUnit.prototype.write = function(line) { * * @param {Test} test */ -XUnit.prototype.test = function(test) { +XUnit.prototype.test = function (test) { var attrs = { classname: test.parent.fullTitle(), name: test.title, @@ -147,7 +149,7 @@ XUnit.prototype.test = function(test) { * @param content * @return {string} */ -function tag(name, attrs, close, content) { +function tag (name, attrs, close, content) { var end = close ? '/>' : '>'; var pairs = []; var tag; diff --git a/tests/lib/mocha-3.1.0/lib/runnable.js b/tests/lib/mocha-3.1.2/lib/runnable.js index 52ee900b22..3edd9abd3e 100644 --- a/tests/lib/mocha-3.1.0/lib/runnable.js +++ b/tests/lib/mocha-3.1.2/lib/runnable.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -43,7 +45,7 @@ module.exports = Runnable; * @param {string} title * @param {Function} fn */ -function Runnable(title, fn) { +function Runnable (title, fn) { this.title = title; this.fn = fn; this.body = (fn || '').toString(); @@ -73,7 +75,7 @@ Runnable.prototype = create(EventEmitter.prototype, { * @param {number|string} ms * @return {Runnable|number} ms or Runnable instance. */ -Runnable.prototype.timeout = function(ms) { +Runnable.prototype.timeout = function (ms) { if (!arguments.length) { return this._timeout; } @@ -99,7 +101,7 @@ Runnable.prototype.timeout = function(ms) { * @param {number|string} ms * @return {Runnable|number} ms or Runnable instance. */ -Runnable.prototype.slow = function(ms) { +Runnable.prototype.slow = function (ms) { if (typeof ms === 'undefined') { return this._slow; } @@ -118,7 +120,7 @@ Runnable.prototype.slow = function(ms) { * @param {boolean} enabled * @return {Runnable|boolean} enabled or Runnable instance. */ -Runnable.prototype.enableTimeouts = function(enabled) { +Runnable.prototype.enableTimeouts = function (enabled) { if (!arguments.length) { return this._enableTimeouts; } @@ -132,7 +134,7 @@ Runnable.prototype.enableTimeouts = function(enabled) { * * @api public */ -Runnable.prototype.skip = function() { +Runnable.prototype.skip = function () { throw new Pending('sync skip'); }; @@ -141,7 +143,7 @@ Runnable.prototype.skip = function() { * * @api private */ -Runnable.prototype.isPending = function() { +Runnable.prototype.isPending = function () { return this.pending || (this.parent && this.parent.isPending()); }; @@ -150,7 +152,7 @@ Runnable.prototype.isPending = function() { * * @api private */ -Runnable.prototype.retries = function(n) { +Runnable.prototype.retries = function (n) { if (!arguments.length) { return this._retries; } @@ -162,7 +164,7 @@ Runnable.prototype.retries = function(n) { * * @api private */ -Runnable.prototype.currentRetry = function(n) { +Runnable.prototype.currentRetry = function (n) { if (!arguments.length) { return this._currentRetry; } @@ -176,7 +178,7 @@ Runnable.prototype.currentRetry = function(n) { * @api public * @return {string} */ -Runnable.prototype.fullTitle = function() { +Runnable.prototype.fullTitle = function () { return this.parent.fullTitle() + ' ' + this.title; }; @@ -185,7 +187,7 @@ Runnable.prototype.fullTitle = function() { * * @api private */ -Runnable.prototype.clearTimeout = function() { +Runnable.prototype.clearTimeout = function () { clearTimeout(this.timer); }; @@ -195,8 +197,8 @@ Runnable.prototype.clearTimeout = function() { * @api private * @return {string} */ -Runnable.prototype.inspect = function() { - return JSON.stringify(this, function(key, val) { +Runnable.prototype.inspect = function () { + return JSON.stringify(this, function (key, val) { if (key[0] === '_') { return; } @@ -215,7 +217,7 @@ Runnable.prototype.inspect = function() { * * @api private */ -Runnable.prototype.resetTimeout = function() { +Runnable.prototype.resetTimeout = function () { var self = this; var ms = this.timeout() || 1e9; @@ -223,7 +225,7 @@ Runnable.prototype.resetTimeout = function() { return; } this.clearTimeout(); - this.timer = setTimeout(function() { + this.timer = setTimeout(function () { if (!self._enableTimeouts) { return; } @@ -238,7 +240,7 @@ Runnable.prototype.resetTimeout = function() { * @api private * @param {string[]} globals */ -Runnable.prototype.globals = function(globals) { +Runnable.prototype.globals = function (globals) { if (!arguments.length) { return this._allowedGlobals; } @@ -251,7 +253,7 @@ Runnable.prototype.globals = function(globals) { * @param {Function} fn * @api private */ -Runnable.prototype.run = function(fn) { +Runnable.prototype.run = function (fn) { var self = this; var start = new Date(); var ctx = this.ctx; @@ -264,7 +266,7 @@ Runnable.prototype.run = function(fn) { } // called multiple times - function multiple(err) { + function multiple (err) { if (emitted) { return; } @@ -273,7 +275,7 @@ Runnable.prototype.run = function(fn) { } // finished - function done(err) { + function done (err) { var ms = self.timeout(); if (self.timedOut) { return; @@ -299,7 +301,7 @@ Runnable.prototype.run = function(fn) { this.resetTimeout(); // allows skip() to be used in an explicit async context - this.skip = function asyncSkip() { + this.skip = function asyncSkip () { done(new Pending('async skip call')); // halt execution. the Runnable will be marked pending // by the previous call, and the uncaught handler will ignore @@ -313,6 +315,7 @@ Runnable.prototype.run = function(fn) { try { callFnAsync(this.fn); } catch (err) { + emitted = true; done(utils.getError(err)); } return; @@ -332,21 +335,22 @@ Runnable.prototype.run = function(fn) { callFn(this.fn); } } catch (err) { + emitted = true; done(utils.getError(err)); } - function callFn(fn) { + function callFn (fn) { var result = fn.call(ctx); if (result && typeof result.then === 'function') { self.resetTimeout(); result - .then(function() { + .then(function () { done(); // Return null so libraries like bluebird do not warn about // subsequently constructed Promises. return null; }, - function(reason) { + function (reason) { done(reason || new Error('Promise rejected with no or falsy reason')); }); } else { @@ -358,15 +362,15 @@ Runnable.prototype.run = function(fn) { } } - function callFnAsync(fn) { - var result = fn.call(ctx, function(err) { + function callFnAsync (fn) { + var result = fn.call(ctx, function (err) { if (err instanceof Error || toString.call(err) === '[object Error]') { return done(err); } if (err) { if (Object.prototype.toString.call(err) === '[object Object]') { - return done(new Error('done() invoked with non-Error: ' - + JSON.stringify(err))); + return done(new Error('done() invoked with non-Error: ' + + JSON.stringify(err))); } return done(new Error('done() invoked with non-Error: ' + err)); } diff --git a/tests/lib/mocha-3.1.0/lib/runner.js b/tests/lib/mocha-3.1.2/lib/runner.js index dc03ec451a..697ffb65ac 100644 --- a/tests/lib/mocha-3.1.0/lib/runner.js +++ b/tests/lib/mocha-3.1.2/lib/runner.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -61,7 +63,7 @@ module.exports = Runner; * @param {boolean} [delay] Whether or not to delay execution of root suite * until ready. */ -function Runner(suite, delay) { +function Runner (suite, delay) { var self = this; this._globals = []; this._abort = false; @@ -70,10 +72,10 @@ function Runner(suite, delay) { this.started = false; this.total = suite.total(); this.failures = 0; - this.on('test end', function(test) { + this.on('test end', function (test) { self.checkGlobals(test); }); - this.on('hook end', function(hook) { + this.on('hook end', function (hook) { self.checkGlobals(hook); }); this._defaultGrep = /.*/; @@ -106,7 +108,7 @@ inherits(Runner, EventEmitter); * @param {boolean} invert * @return {Runner} Runner instance. */ -Runner.prototype.grep = function(re, invert) { +Runner.prototype.grep = function (re, invert) { debug('grep %s', re); this._grep = re; this._invert = invert; @@ -124,11 +126,11 @@ Runner.prototype.grep = function(re, invert) { * @param {Suite} suite * @return {number} */ -Runner.prototype.grepTotal = function(suite) { +Runner.prototype.grepTotal = function (suite) { var self = this; var total = 0; - suite.eachTest(function(test) { + suite.eachTest(function (test) { var match = self._grep.test(test.fullTitle()); if (self._invert) { match = !match; @@ -147,7 +149,7 @@ Runner.prototype.grepTotal = function(suite) { * @return {Array} * @api private */ -Runner.prototype.globalProps = function() { +Runner.prototype.globalProps = function () { var props = keys(global); // non-enumerables @@ -170,7 +172,7 @@ Runner.prototype.globalProps = function() { * @param {Array} arr * @return {Runner} Runner instance. */ -Runner.prototype.globals = function(arr) { +Runner.prototype.globals = function (arr) { if (!arguments.length) { return this._globals; } @@ -184,7 +186,7 @@ Runner.prototype.globals = function(arr) { * * @api private */ -Runner.prototype.checkGlobals = function(test) { +Runner.prototype.checkGlobals = function (test) { if (this.ignoreLeaks) { return; } @@ -219,7 +221,7 @@ Runner.prototype.checkGlobals = function(test) { * @param {Test} test * @param {Error} err */ -Runner.prototype.fail = function(test, err) { +Runner.prototype.fail = function (test, err) { if (test.isPending()) { return; } @@ -231,9 +233,13 @@ Runner.prototype.fail = function(test, err) { err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'); } - err.stack = (this.fullStackTrace || !err.stack) - ? err.stack - : stackFilter(err.stack); + try { + err.stack = (this.fullStackTrace || !err.stack) + ? err.stack + : stackFilter(err.stack); + } catch (ignored) { + // some environments do not take kindly to monkeying with the stack + } this.emit('fail', test, err); }; @@ -258,7 +264,7 @@ Runner.prototype.fail = function(test, err) { * @param {Hook} hook * @param {Error} err */ -Runner.prototype.failHook = function(hook, err) { +Runner.prototype.failHook = function (hook, err) { if (hook.ctx && hook.ctx.currentTest) { hook.originalTitle = hook.originalTitle || hook.title; hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"'; @@ -278,12 +284,12 @@ Runner.prototype.failHook = function(hook, err) { * @param {Function} fn */ -Runner.prototype.hook = function(name, fn) { +Runner.prototype.hook = function (name, fn) { var suite = this.suite; var hooks = suite['_' + name]; var self = this; - function next(i) { + function next (i) { var hook = hooks[i]; if (!hook) { return fn(); @@ -295,12 +301,12 @@ Runner.prototype.hook = function(name, fn) { self.emit('hook', hook); if (!hook.listeners('error').length) { - hook.on('error', function(err) { + hook.on('error', function (err) { self.failHook(hook, err); }); } - hook.run(function(err) { + hook.run(function (err) { var testError = hook.error(); if (testError) { self.fail(self.test, testError); @@ -310,7 +316,7 @@ Runner.prototype.hook = function(name, fn) { if (name === 'beforeEach' || name === 'afterEach') { self.test.pending = true; } else { - utils.forEach(suite.tests, function(test) { + utils.forEach(suite.tests, function (test) { test.pending = true; }); // a pending hook won't be executed twice. @@ -329,7 +335,7 @@ Runner.prototype.hook = function(name, fn) { }); } - Runner.immediately(function() { + Runner.immediately(function () { next(0); }); }; @@ -343,11 +349,11 @@ Runner.prototype.hook = function(name, fn) { * @param {Array} suites * @param {Function} fn */ -Runner.prototype.hooks = function(name, suites, fn) { +Runner.prototype.hooks = function (name, suites, fn) { var self = this; var orig = this.suite; - function next(suite) { + function next (suite) { self.suite = suite; if (!suite) { @@ -355,7 +361,7 @@ Runner.prototype.hooks = function(name, suites, fn) { return fn(); } - self.hook(name, function(err) { + self.hook(name, function (err) { if (err) { var errSuite = self.suite; self.suite = orig; @@ -376,7 +382,7 @@ Runner.prototype.hooks = function(name, suites, fn) { * @param {Function} fn * @api private */ -Runner.prototype.hookUp = function(name, fn) { +Runner.prototype.hookUp = function (name, fn) { var suites = [this.suite].concat(this.parents()).reverse(); this.hooks(name, suites, fn); }; @@ -388,7 +394,7 @@ Runner.prototype.hookUp = function(name, fn) { * @param {Function} fn * @api private */ -Runner.prototype.hookDown = function(name, fn) { +Runner.prototype.hookDown = function (name, fn) { var suites = [this.suite].concat(this.parents()); this.hooks(name, suites, fn); }; @@ -400,7 +406,7 @@ Runner.prototype.hookDown = function(name, fn) { * @return {Array} * @api private */ -Runner.prototype.parents = function() { +Runner.prototype.parents = function () { var suite = this.suite; var suites = []; while (suite.parent) { @@ -416,7 +422,7 @@ Runner.prototype.parents = function() { * @param {Function} fn * @api private */ -Runner.prototype.runTest = function(fn) { +Runner.prototype.runTest = function (fn) { var self = this; var test = this.test; @@ -432,7 +438,7 @@ Runner.prototype.runTest = function(fn) { return test.run(fn); } try { - test.on('error', function(err) { + test.on('error', function (err) { self.fail(test, err); }); test.run(fn); @@ -448,12 +454,12 @@ Runner.prototype.runTest = function(fn) { * @param {Suite} suite * @param {Function} fn */ -Runner.prototype.runTests = function(suite, fn) { +Runner.prototype.runTests = function (suite, fn) { var self = this; var tests = suite.tests.slice(); var test; - function hookErr(_, errSuite, after) { + function hookErr (_, errSuite, after) { // before/after Each hook for errSuite failed: var orig = self.suite; @@ -463,7 +469,7 @@ Runner.prototype.runTests = function(suite, fn) { if (self.suite) { // call hookUp afterEach - self.hookUp('afterEach', function(err2, errSuite2) { + self.hookUp('afterEach', function (err2, errSuite2) { self.suite = orig; // some hooks may fail even now if (err2) { @@ -479,7 +485,7 @@ Runner.prototype.runTests = function(suite, fn) { } } - function next(err, errSuite) { + function next (err, errSuite) { // if we bail after first err if (self.failures && suite._bail) { return fn(); @@ -531,7 +537,7 @@ Runner.prototype.runTests = function(suite, fn) { // execute test and hook(s) self.emit('test', self.test = test); - self.hookDown('beforeEach', function(err, errSuite) { + self.hookDown('beforeEach', function (err, errSuite) { if (test.isPending()) { self.emit('pending', test); self.emit('test end', test); @@ -541,7 +547,7 @@ Runner.prototype.runTests = function(suite, fn) { return hookErr(err, errSuite, false); } self.currentRunnable = self.test; - self.runTest(function(err) { + self.runTest(function (err) { test = self.test; if (err) { var retry = test.currentRetry(); @@ -588,7 +594,7 @@ Runner.prototype.runTests = function(suite, fn) { * @param {Suite} suite * @param {Function} fn */ -Runner.prototype.runSuite = function(suite, fn) { +Runner.prototype.runSuite = function (suite, fn) { var i = 0; var self = this; var total = this.grepTotal(suite); @@ -602,7 +608,7 @@ Runner.prototype.runSuite = function(suite, fn) { this.emit('suite', this.suite = suite); - function next(errSuite) { + function next (errSuite) { if (errSuite) { // current suite failed on a hook from errSuite if (errSuite === suite) { @@ -628,7 +634,7 @@ Runner.prototype.runSuite = function(suite, fn) { // huge recursive loop and thus a maximum call stack error. // See comment in `this.runTests()` for more information. if (self._grep !== self._defaultGrep) { - Runner.immediately(function() { + Runner.immediately(function () { self.runSuite(curr, next); }); } else { @@ -636,7 +642,7 @@ Runner.prototype.runSuite = function(suite, fn) { } } - function done(errSuite) { + function done (errSuite) { self.suite = suite; self.nextSuite = next; @@ -650,7 +656,7 @@ Runner.prototype.runSuite = function(suite, fn) { // remove reference to test delete self.test; - self.hook('afterAll', function() { + self.hook('afterAll', function () { self.emit('suite end', suite); fn(errSuite); }); @@ -659,7 +665,7 @@ Runner.prototype.runSuite = function(suite, fn) { this.nextSuite = next; - this.hook('beforeAll', function(err) { + this.hook('beforeAll', function (err) { if (err) { return done(); } @@ -673,9 +679,9 @@ Runner.prototype.runSuite = function(suite, fn) { * @param {Error} err * @api private */ -Runner.prototype.uncaught = function(err) { +Runner.prototype.uncaught = function (err) { if (err) { - debug('uncaught exception %s', err !== function() { + debug('uncaught exception %s', err !== function () { return this; }.call(err) ? err : (err.message || err)); } else { @@ -746,8 +752,8 @@ Runner.prototype.uncaught = function(err) { * * @param {Suite} suite */ -function cleanSuiteReferences(suite) { - function cleanArrReferences(arr) { +function cleanSuiteReferences (suite) { + function cleanArrReferences (arr) { for (var i = 0; i < arr.length; i++) { delete arr[i].fn; } @@ -784,7 +790,7 @@ function cleanSuiteReferences(suite) { * @param {Function} fn * @return {Runner} Runner instance. */ -Runner.prototype.run = function(fn) { +Runner.prototype.run = function (fn) { var self = this; var rootSuite = this.suite; @@ -793,16 +799,16 @@ Runner.prototype.run = function(fn) { filterOnly(rootSuite); } - fn = fn || function() {}; + fn = fn || function () {}; - function uncaught(err) { + function uncaught (err) { self.uncaught(err); } - function start() { + function start () { self.started = true; self.emit('start'); - self.runSuite(rootSuite, function() { + self.runSuite(rootSuite, function () { debug('finished running'); self.emit('end'); }); @@ -814,7 +820,7 @@ Runner.prototype.run = function(fn) { this.on('suite end', cleanSuiteReferences); // callback - this.on('end', function() { + this.on('end', function () { debug('end'); process.removeListener('uncaughtException', uncaught); fn(self.failures); @@ -841,7 +847,7 @@ Runner.prototype.run = function(fn) { * @api public * @return {Runner} Runner instance. */ -Runner.prototype.abort = function() { +Runner.prototype.abort = function () { debug('aborting'); this._abort = true; @@ -855,7 +861,7 @@ Runner.prototype.abort = function() { * @returns {Boolean} * @api private */ -function filterOnly(suite) { +function filterOnly (suite) { if (suite._onlyTests.length) { // If the suite contains `only` tests, run those and ignore any nested suites. suite.tests = suite._onlyTests; @@ -863,7 +869,7 @@ function filterOnly(suite) { } else { // Otherwise, do not run any of the tests in this suite. suite.tests = []; - utils.forEach(suite._onlySuites, function(onlySuite) { + utils.forEach(suite._onlySuites, function (onlySuite) { // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite. // Otherwise, all of the tests on this `only` suite should be run, so don't filter it. if (hasOnly(onlySuite)) { @@ -871,7 +877,7 @@ function filterOnly(suite) { } }); // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants. - suite.suites = filter(suite.suites, function(childSuite) { + suite.suites = filter(suite.suites, function (childSuite) { return indexOf(suite._onlySuites, childSuite) !== -1 || filterOnly(childSuite); }); } @@ -886,7 +892,7 @@ function filterOnly(suite) { * @returns {Boolean} * @api private */ -function hasOnly(suite) { +function hasOnly (suite) { return suite._onlyTests.length || suite._onlySuites.length || some(suite.suites, hasOnly); } @@ -898,8 +904,8 @@ function hasOnly(suite) { * @param {Array} globals * @return {Array} */ -function filterLeaks(ok, globals) { - return filter(globals, function(key) { +function filterLeaks (ok, globals) { + return filter(globals, function (key) { // Firefox and Chrome exposes iframes as index inside the window object if (/^\d+/.test(key)) { return false; @@ -923,7 +929,7 @@ function filterLeaks(ok, globals) { return false; } - var matched = filter(ok, function(ok) { + var matched = filter(ok, function (ok) { if (~ok.indexOf('*')) { return key.indexOf(ok.split('*')[0]) === 0; } @@ -939,10 +945,10 @@ function filterLeaks(ok, globals) { * @return {Array} * @api private */ -function extraGlobals() { +function extraGlobals () { if (typeof process === 'object' && typeof process.version === 'string') { var parts = process.version.split('.'); - var nodeVersion = utils.reduce(parts, function(a, v) { + var nodeVersion = utils.reduce(parts, function (a, v) { return a << 8 | v; }); diff --git a/tests/lib/mocha-3.1.0/lib/suite.js b/tests/lib/mocha-3.1.2/lib/suite.js index bf3e4e9fef..13617ab91d 100644 --- a/tests/lib/mocha-3.1.0/lib/suite.js +++ b/tests/lib/mocha-3.1.2/lib/suite.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -25,7 +27,7 @@ exports = module.exports = Suite; * @param {string} title * @return {Suite} */ -exports.create = function(parent, title) { +exports.create = function (parent, title) { var suite = new Suite(title, parent.ctx); suite.parent = parent; title = suite.fullTitle(); @@ -40,12 +42,12 @@ exports.create = function(parent, title) { * @param {string} title * @param {Context} parentContext */ -function Suite(title, parentContext) { +function Suite (title, parentContext) { if (!utils.isString(title)) { throw new Error('Suite `title` should be a "string" but "' + typeof title + '" was given instead.'); } this.title = title; - function Context() {} + function Context () {} Context.prototype = parentContext; this.ctx = new Context(); this.suites = []; @@ -77,7 +79,7 @@ inherits(Suite, EventEmitter); * @api private * @return {Suite} */ -Suite.prototype.clone = function() { +Suite.prototype.clone = function () { var suite = new Suite(this.title); debug('clone'); suite.ctx = this.ctx; @@ -96,7 +98,7 @@ Suite.prototype.clone = function() { * @param {number|string} ms * @return {Suite|number} for chaining */ -Suite.prototype.timeout = function(ms) { +Suite.prototype.timeout = function (ms) { if (!arguments.length) { return this._timeout; } @@ -118,7 +120,7 @@ Suite.prototype.timeout = function(ms) { * @param {number|string} n * @return {Suite|number} for chaining */ -Suite.prototype.retries = function(n) { +Suite.prototype.retries = function (n) { if (!arguments.length) { return this._retries; } @@ -134,7 +136,7 @@ Suite.prototype.retries = function(n) { * @param {boolean} enabled * @return {Suite|boolean} self or enabled */ -Suite.prototype.enableTimeouts = function(enabled) { +Suite.prototype.enableTimeouts = function (enabled) { if (!arguments.length) { return this._enableTimeouts; } @@ -150,7 +152,7 @@ Suite.prototype.enableTimeouts = function(enabled) { * @param {number|string} ms * @return {Suite|number} for chaining */ -Suite.prototype.slow = function(ms) { +Suite.prototype.slow = function (ms) { if (!arguments.length) { return this._slow; } @@ -169,7 +171,7 @@ Suite.prototype.slow = function(ms) { * @param {boolean} bail * @return {Suite|number} for chaining */ -Suite.prototype.bail = function(bail) { +Suite.prototype.bail = function (bail) { if (!arguments.length) { return this._bail; } @@ -183,7 +185,7 @@ Suite.prototype.bail = function(bail) { * * @api private */ -Suite.prototype.isPending = function() { +Suite.prototype.isPending = function () { return this.pending || (this.parent && this.parent.isPending()); }; @@ -195,7 +197,7 @@ Suite.prototype.isPending = function() { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.beforeAll = function(title, fn) { +Suite.prototype.beforeAll = function (title, fn) { if (this.isPending()) { return this; } @@ -225,7 +227,7 @@ Suite.prototype.beforeAll = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.afterAll = function(title, fn) { +Suite.prototype.afterAll = function (title, fn) { if (this.isPending()) { return this; } @@ -255,7 +257,7 @@ Suite.prototype.afterAll = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.beforeEach = function(title, fn) { +Suite.prototype.beforeEach = function (title, fn) { if (this.isPending()) { return this; } @@ -285,7 +287,7 @@ Suite.prototype.beforeEach = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.afterEach = function(title, fn) { +Suite.prototype.afterEach = function (title, fn) { if (this.isPending()) { return this; } @@ -314,7 +316,7 @@ Suite.prototype.afterEach = function(title, fn) { * @param {Suite} suite * @return {Suite} for chaining */ -Suite.prototype.addSuite = function(suite) { +Suite.prototype.addSuite = function (suite) { suite.parent = this; suite.timeout(this.timeout()); suite.retries(this.retries()); @@ -333,7 +335,7 @@ Suite.prototype.addSuite = function(suite) { * @param {Test} test * @return {Suite} for chaining */ -Suite.prototype.addTest = function(test) { +Suite.prototype.addTest = function (test) { test.parent = this; test.timeout(this.timeout()); test.retries(this.retries()); @@ -352,7 +354,7 @@ Suite.prototype.addTest = function(test) { * @api public * @return {string} */ -Suite.prototype.fullTitle = function() { +Suite.prototype.fullTitle = function () { if (this.parent) { var full = this.parent.fullTitle(); if (full) { @@ -368,8 +370,8 @@ Suite.prototype.fullTitle = function() { * @api public * @return {number} */ -Suite.prototype.total = function() { - return utils.reduce(this.suites, function(sum, suite) { +Suite.prototype.total = function () { + return utils.reduce(this.suites, function (sum, suite) { return sum + suite.total(); }, 0) + this.tests.length; }; @@ -382,9 +384,9 @@ Suite.prototype.total = function() { * @param {Function} fn * @return {Suite} */ -Suite.prototype.eachTest = function(fn) { +Suite.prototype.eachTest = function (fn) { utils.forEach(this.tests, fn); - utils.forEach(this.suites, function(suite) { + utils.forEach(this.suites, function (suite) { suite.eachTest(fn); }); return this; @@ -393,7 +395,7 @@ Suite.prototype.eachTest = function(fn) { /** * This will run the root suite if we happen to be running in delayed mode. */ -Suite.prototype.run = function run() { +Suite.prototype.run = function run () { if (this.root) { this.emit('run'); } diff --git a/tests/lib/mocha-3.1.0/lib/template.html b/tests/lib/mocha-3.1.2/lib/template.html index 36c5e0b694..36c5e0b694 100644 --- a/tests/lib/mocha-3.1.0/lib/template.html +++ b/tests/lib/mocha-3.1.2/lib/template.html diff --git a/tests/lib/mocha-3.1.0/lib/test.js b/tests/lib/mocha-3.1.2/lib/test.js index 05d4ed86d5..66bb57cb42 100644 --- a/tests/lib/mocha-3.1.0/lib/test.js +++ b/tests/lib/mocha-3.1.2/lib/test.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Module dependencies. */ @@ -19,7 +21,7 @@ module.exports = Test; * @param {String} title * @param {Function} fn */ -function Test(title, fn) { +function Test (title, fn) { if (!isString(title)) { throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.'); } @@ -35,7 +37,7 @@ Test.prototype = create(Runnable.prototype, { constructor: Test }); -Test.prototype.clone = function() { +Test.prototype.clone = function () { var test = new Test(this.title, this.fn); test.timeout(this.timeout()); test.slow(this.slow()); diff --git a/tests/lib/mocha-3.1.0/lib/to-iso-string/LICENSE b/tests/lib/mocha-3.1.2/lib/to-iso-string/LICENSE index c25db56595..c25db56595 100644 --- a/tests/lib/mocha-3.1.0/lib/to-iso-string/LICENSE +++ b/tests/lib/mocha-3.1.2/lib/to-iso-string/LICENSE diff --git a/tests/lib/mocha-3.1.0/lib/to-iso-string/index.js b/tests/lib/mocha-3.1.2/lib/to-iso-string/index.js index cd28d7be71..cd28d7be71 100644 --- a/tests/lib/mocha-3.1.0/lib/to-iso-string/index.js +++ b/tests/lib/mocha-3.1.2/lib/to-iso-string/index.js diff --git a/tests/lib/mocha-3.1.0/lib/utils.js b/tests/lib/mocha-3.1.2/lib/utils.js index c7947cb05d..2af3aac448 100644 --- a/tests/lib/mocha-3.1.0/lib/utils.js +++ b/tests/lib/mocha-3.1.2/lib/utils.js @@ -1,3 +1,5 @@ +'use strict'; + /* eslint-env browser */ /** @@ -31,7 +33,7 @@ exports.inherits = require('util').inherits; * @param {string} html * @return {string} */ -exports.escape = function(html) { +exports.escape = function (html) { return String(html) .replace(/&/g, '&') .replace(/"/g, '"') @@ -47,7 +49,7 @@ exports.escape = function(html) { * @param {Function} fn * @param {Object} scope */ -exports.forEach = function(arr, fn, scope) { +exports.forEach = function (arr, fn, scope) { for (var i = 0, l = arr.length; i < l; i++) { fn.call(scope, arr[i], i); } @@ -60,7 +62,7 @@ exports.forEach = function(arr, fn, scope) { * @param {Object} obj * @return {boolean} */ -exports.isString = function(obj) { +exports.isString = function (obj) { return typeof obj === 'string'; }; @@ -73,7 +75,7 @@ exports.isString = function(obj) { * @param {Object} scope * @return {Array} */ -exports.map = function(arr, fn, scope) { +exports.map = function (arr, fn, scope) { var result = []; for (var i = 0, l = arr.length; i < l; i++) { result.push(fn.call(scope, arr[i], i, arr)); @@ -90,7 +92,7 @@ exports.map = function(arr, fn, scope) { * @param {number} start * @return {number} */ -var indexOf = exports.indexOf = function(arr, obj, start) { +var indexOf = exports.indexOf = function (arr, obj, start) { for (var i = start || 0, l = arr.length; i < l; i++) { if (arr[i] === obj) { return i; @@ -108,7 +110,7 @@ var indexOf = exports.indexOf = function(arr, obj, start) { * @param {Object} val Initial value. * @return {*} */ -var reduce = exports.reduce = function(arr, fn, val) { +var reduce = exports.reduce = function (arr, fn, val) { var rval = val; for (var i = 0, l = arr.length; i < l; i++) { @@ -126,7 +128,7 @@ var reduce = exports.reduce = function(arr, fn, val) { * @param {Function} fn * @return {Array} */ -exports.filter = function(arr, fn) { +exports.filter = function (arr, fn) { var ret = []; for (var i = 0, l = arr.length; i < l; i++) { @@ -147,7 +149,7 @@ exports.filter = function(arr, fn) { * @param {Function} fn * @return {Array} */ -exports.some = function(arr, fn) { +exports.some = function (arr, fn) { for (var i = 0, l = arr.length; i < l; i++) { if (fn(arr[i])) { return true; @@ -163,7 +165,7 @@ exports.some = function(arr, fn) { * @param {Object} obj * @return {Array} keys */ -exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) { +exports.keys = typeof Object.keys === 'function' ? Object.keys : function (obj) { var keys = []; var has = Object.prototype.hasOwnProperty; // for `window` on <=IE8 @@ -184,11 +186,11 @@ exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) { * @param {Array} files * @param {Function} fn */ -exports.watch = function(files, fn) { +exports.watch = function (files, fn) { var options = { interval: 100 }; - files.forEach(function(file) { + files.forEach(function (file) { debug('file %s', file); - watchFile(file, options, function(curr, prev) { + watchFile(file, options, function (curr, prev) { if (prev.mtime < curr.mtime) { fn(file); } @@ -203,7 +205,7 @@ exports.watch = function(files, fn) { * @param {Object} obj * @return {Boolean} */ -var isArray = typeof Array.isArray === 'function' ? Array.isArray : function(obj) { +var isArray = typeof Array.isArray === 'function' ? Array.isArray : function (obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; @@ -215,7 +217,7 @@ exports.isArray = isArray; * @type {Function} */ if (typeof Buffer !== 'undefined' && Buffer.prototype) { - Buffer.prototype.toJSON = Buffer.prototype.toJSON || function() { + Buffer.prototype.toJSON = Buffer.prototype.toJSON || function () { return Array.prototype.slice.call(this, 0); }; } @@ -227,7 +229,7 @@ if (typeof Buffer !== 'undefined' && Buffer.prototype) { * @param {string} path * @return {boolean} */ -function ignored(path) { +function ignored (path) { return !~ignore.indexOf(path); } @@ -240,7 +242,7 @@ function ignored(path) { * @param {Array} [ret=[]] * @return {Array} */ -exports.files = function(dir, ext, ret) { +exports.files = function (dir, ext, ret) { ret = ret || []; ext = ext || ['js']; @@ -248,7 +250,7 @@ exports.files = function(dir, ext, ret) { readdirSync(dir) .filter(ignored) - .forEach(function(path) { + .forEach(function (path) { path = join(dir, path); if (statSync(path).isDirectory()) { exports.files(path, ext, ret); @@ -267,7 +269,7 @@ exports.files = function(dir, ext, ret) { * @param {string} str * @return {string} */ -exports.slug = function(str) { +exports.slug = function (str) { return str .toLowerCase() .replace(/ +/g, '-') @@ -280,7 +282,7 @@ exports.slug = function(str) { * @param {string} str * @return {string} */ -exports.clean = function(str) { +exports.clean = function (str) { str = str .replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '') // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content @@ -288,7 +290,7 @@ exports.clean = function(str) { var spaces = str.match(/^\n?( *)/)[1].length; var tabs = str.match(/^\n?(\t*)/)[1].length; - var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm'); + var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm'); str = str.replace(re, ''); @@ -302,7 +304,7 @@ exports.clean = function(str) { * @param {string} str * @return {string} */ -exports.trim = function(str) { +exports.trim = function (str) { return str.replace(/^\s+|\s+$/g, ''); }; @@ -313,8 +315,8 @@ exports.trim = function(str) { * @param {string} qs * @return {Object} */ -exports.parseQuery = function(qs) { - return reduce(qs.replace('?', '').split('&'), function(obj, pair) { +exports.parseQuery = function (qs) { + return reduce(qs.replace('?', '').split('&'), function (obj, pair) { var i = pair.indexOf('='); var key = pair.slice(0, i); var val = pair.slice(++i); @@ -331,7 +333,7 @@ exports.parseQuery = function(qs) { * @param {string} js * @return {string} */ -function highlight(js) { +function highlight (js) { return js .replace(/</g, '<') .replace(/>/g, '>') @@ -349,7 +351,7 @@ function highlight(js) { * @api private * @param {string} name */ -exports.highlightTags = function(name) { +exports.highlightTags = function (name) { var code = document.getElementById('mocha').getElementsByTagName(name); for (var i = 0, len = code.length; i < len; ++i) { code[i].innerHTML = highlight(code[i].innerHTML); @@ -370,7 +372,7 @@ exports.highlightTags = function(name) { * @param {string} typeHint The type of the value * @returns {string} */ -function emptyRepresentation(value, typeHint) { +function emptyRepresentation (value, typeHint) { switch (typeHint) { case 'function': return '[Function]'; @@ -404,7 +406,7 @@ function emptyRepresentation(value, typeHint) { * type(global) // 'global' * type(new String('foo') // 'object' */ -var type = exports.type = function type(value) { +var type = exports.type = function type (value) { if (value === undefined) { return 'undefined'; } else if (value === null) { @@ -432,7 +434,7 @@ var type = exports.type = function type(value) { * @param {*} value * @return {string} */ -exports.stringify = function(value) { +exports.stringify = function (value) { var typeHint = type(value); if (!~indexOf(['object', 'array', 'function'], typeHint)) { @@ -446,7 +448,7 @@ exports.stringify = function(value) { // IE7/IE8 has a bizarre String constructor; needs to be coerced // into an array and back to obj. if (typeHint === 'string' && typeof value === 'object') { - value = reduce(value.split(''), function(acc, char, idx) { + value = reduce(value.split(''), function (acc, char, idx) { acc[idx] = char; return acc; }, {}); @@ -474,7 +476,7 @@ exports.stringify = function(value) { * @param {number=} depth * @returns {*} */ -function jsonStringify(object, spaces, depth) { +function jsonStringify (object, spaces, depth) { if (typeof spaces === 'undefined') { // primitive types return _stringify(object); @@ -486,11 +488,11 @@ function jsonStringify(object, spaces, depth) { var end = isArray(object) ? ']' : '}'; var length = typeof object.length === 'number' ? object.length : exports.keys(object).length; // `.repeat()` polyfill - function repeat(s, n) { + function repeat (s, n) { return new Array(n).join(s); } - function _stringify(val) { + function _stringify (val) { switch (type(val)) { case 'null': case 'undefined': @@ -536,15 +538,15 @@ function jsonStringify(object, spaces, depth) { continue; // not my business } --length; - str += '\n ' + repeat(' ', space) - + (isArray(object) ? '' : '"' + i + '": ') // key - + _stringify(object[i]) // value - + (length ? ',' : ''); // comma + str += '\n ' + repeat(' ', space) + + (isArray(object) ? '' : '"' + i + '": ') + // key + _stringify(object[i]) + // value + (length ? ',' : ''); // comma } - return str + return str + // [], {} - + (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end); + (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end); } /** @@ -554,7 +556,7 @@ function jsonStringify(object, spaces, depth) { * @param {*} value The value to test. * @return {boolean} True if `value` is a buffer, otherwise false */ -exports.isBuffer = function(value) { +exports.isBuffer = function (value) { return typeof Buffer !== 'undefined' && Buffer.isBuffer(value); }; @@ -577,13 +579,13 @@ exports.isBuffer = function(value) { * @param {string} [typeHint] Type hint * @return {(Object|Array|Function|string|undefined)} */ -exports.canonicalize = function canonicalize(value, stack, typeHint) { +exports.canonicalize = function canonicalize (value, stack, typeHint) { var canonicalizedObj; /* eslint-disable no-unused-vars */ var prop; /* eslint-enable no-unused-vars */ typeHint = typeHint || type(value); - function withStack(value, fn) { + function withStack (value, fn) { stack.push(value); fn(); stack.pop(); @@ -602,8 +604,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { canonicalizedObj = value; break; case 'array': - withStack(value, function() { - canonicalizedObj = exports.map(value, function(item) { + withStack(value, function () { + canonicalizedObj = exports.map(value, function (item) { return exports.canonicalize(item, stack); }); }); @@ -622,8 +624,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { /* falls through */ case 'object': canonicalizedObj = canonicalizedObj || {}; - withStack(value, function() { - exports.forEach(exports.keys(value).sort(), function(key) { + withStack(value, function () { + exports.forEach(exports.keys(value).sort(), function (key) { canonicalizedObj[key] = exports.canonicalize(value[key], stack); }); }); @@ -651,7 +653,7 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { * @param {boolean} recursive Whether or not to recurse into subdirectories. * @return {string[]} An array of paths. */ -exports.lookupFiles = function lookupFiles(path, extensions, recursive) { +exports.lookupFiles = function lookupFiles (path, extensions, recursive) { var files = []; var re = new RegExp('\\.(' + extensions.join('|') + ')$'); @@ -677,7 +679,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) { return; } - readdirSync(path).forEach(function(file) { + readdirSync(path).forEach(function (file) { file = join(path, file); try { var stat = statSync(file); @@ -706,7 +708,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) { * @return {Error} */ -exports.undefinedError = function() { +exports.undefinedError = function () { return new Error('Caught undefined error, did you throw without specifying what?'); }; @@ -717,7 +719,7 @@ exports.undefinedError = function() { * @return {Error} */ -exports.getError = function(err) { +exports.getError = function (err) { return err || exports.undefinedError(); }; @@ -730,7 +732,7 @@ exports.getError = function(err) { * (i.e: strip Mocha and internal node functions from stack trace). * @returns {Function} */ -exports.stackTraceFilter = function() { +exports.stackTraceFilter = function () { // TODO: Replace with `process.browser` var is = typeof document === 'undefined' ? { node: true } : { browser: true }; var slash = path.sep; @@ -742,26 +744,26 @@ exports.stackTraceFilter = function() { slash = '/'; } - function isMochaInternal(line) { - return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) - || (~line.indexOf('node_modules' + slash + 'mocha.js')) - || (~line.indexOf('bower_components' + slash + 'mocha.js')) - || (~line.indexOf(slash + 'mocha.js')); + function isMochaInternal (line) { + return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) || + (~line.indexOf('node_modules' + slash + 'mocha.js')) || + (~line.indexOf('bower_components' + slash + 'mocha.js')) || + (~line.indexOf(slash + 'mocha.js')); } - function isNodeInternal(line) { - return (~line.indexOf('(timers.js:')) - || (~line.indexOf('(events.js:')) - || (~line.indexOf('(node.js:')) - || (~line.indexOf('(module.js:')) - || (~line.indexOf('GeneratorFunctionPrototype.next (native)')) - || false; + function isNodeInternal (line) { + return (~line.indexOf('(timers.js:')) || + (~line.indexOf('(events.js:')) || + (~line.indexOf('(node.js:')) || + (~line.indexOf('(module.js:')) || + (~line.indexOf('GeneratorFunctionPrototype.next (native)')) || + false; } - return function(stack) { + return function (stack) { stack = stack.split('\n'); - stack = reduce(stack, function(list, line) { + stack = reduce(stack, function (list, line) { if (isMochaInternal(line)) { return list; } @@ -789,6 +791,12 @@ exports.stackTraceFilter = function() { * @param {*} value * @returns {boolean} Whether or not `value` is a Promise */ -exports.isPromise = function isPromise(value) { +exports.isPromise = function isPromise (value) { return typeof value === 'object' && typeof value.then === 'function'; }; + +/** + * It's a noop. + * @api + */ +exports.noop = function () {}; diff --git a/tests/lib/mocha-3.1.0/media/logo.svg b/tests/lib/mocha-3.1.2/media/logo.svg index bc3cb4b5df..bc3cb4b5df 100644 --- a/tests/lib/mocha-3.1.0/media/logo.svg +++ b/tests/lib/mocha-3.1.2/media/logo.svg diff --git a/tests/lib/mocha-3.1.0/mocha.css b/tests/lib/mocha-3.1.2/mocha.css index ec96b003c9..ec96b003c9 100644 --- a/tests/lib/mocha-3.1.0/mocha.css +++ b/tests/lib/mocha-3.1.2/mocha.css diff --git a/tests/lib/mocha-3.1.0/mocha.js b/tests/lib/mocha-3.1.2/mocha.js index 1d5b072aca..16d5619e27 100644 --- a/tests/lib/mocha-3.1.0/mocha.js +++ b/tests/lib/mocha-3.1.2/mocha.js @@ -1,6 +1,9 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function (process,global){ +'use strict'; + /* eslint no-unused-vars: off */ +/* eslint-env commonjs */ /** * Shim process.stdout. @@ -37,12 +40,12 @@ var originalOnerrorHandler = global.onerror; * Revert to original onerror handler if previously defined. */ -process.removeListener = function(e, fn) { +process.removeListener = function (e, fn) { if (e === 'uncaughtException') { if (originalOnerrorHandler) { global.onerror = originalOnerrorHandler; } else { - global.onerror = function() {}; + global.onerror = function () {}; } var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn); if (i !== -1) { @@ -55,9 +58,9 @@ process.removeListener = function(e, fn) { * Implements uncaughtException listener. */ -process.on = function(e, fn) { +process.on = function (e, fn) { if (e === 'uncaughtException') { - global.onerror = function(err, url, line) { + global.onerror = function (err, url, line) { fn(new Error(err + ' (' + url + ':' + line + ')')); return !mocha.allowUncaught; }; @@ -73,7 +76,7 @@ mocha.suite.removeAllListeners('pre-require'); var immediateQueue = []; var immediateTimeout; -function timeslice() { +function timeslice () { var immediateStart = new Date().getTime(); while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) { immediateQueue.shift()(); @@ -89,7 +92,7 @@ function timeslice() { * High-performance override of Runner.immediately. */ -Mocha.Runner.immediately = function(callback) { +Mocha.Runner.immediately = function (callback) { immediateQueue.push(callback); if (!immediateTimeout) { immediateTimeout = setTimeout(timeslice, 0); @@ -101,8 +104,8 @@ Mocha.Runner.immediately = function(callback) { * This is useful when running tests in a browser because window.onerror will * only receive the 'message' attribute of the Error. */ -mocha.throwError = function(err) { - Mocha.utils.forEach(uncaughtExceptionHandlers, function(fn) { +mocha.throwError = function (err) { + Mocha.utils.forEach(uncaughtExceptionHandlers, function (fn) { fn(err); }); throw err; @@ -113,7 +116,7 @@ mocha.throwError = function(err) { * Normally this would happen in Mocha.prototype.loadFiles. */ -mocha.ui = function(ui) { +mocha.ui = function (ui) { Mocha.prototype.ui.call(this, ui); this.suite.emit('pre-require', global, null, this); return this; @@ -123,7 +126,7 @@ mocha.ui = function(ui) { * Setup mocha with the given setting options. */ -mocha.setup = function(opts) { +mocha.setup = function (opts) { if (typeof opts === 'string') { opts = { ui: opts }; } @@ -139,7 +142,7 @@ mocha.setup = function(opts) { * Run mocha, returning the Runner. */ -mocha.run = function(fn) { +mocha.run = function (fn) { var options = mocha.options; mocha.globals('location'); @@ -154,7 +157,7 @@ mocha.run = function(fn) { mocha.invert(); } - return Mocha.prototype.run.call(mocha, function(err) { + return Mocha.prototype.run.call(mocha, function (err) { // The DOM Document is not available in Web Workers. var document = global.document; if (document && document.getElementById('mocha') && options.noHighlighting !== true) { @@ -187,12 +190,17 @@ module.exports = global; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./lib/mocha":14,"_process":67,"browser-stdout":41}],2:[function(require,module,exports){ -/* eslint-disable no-unused-vars */ -module.exports = function(type) { - return function() {}; +'use strict'; + +function noop () {} + +module.exports = function () { + return noop; }; },{}],3:[function(require,module,exports){ +'use strict'; + /** * Module exports. */ @@ -211,7 +219,7 @@ var objToString = Object.prototype.toString; * @param {*} val The value to test. * @return {boolean} true if the value is an array, otherwise false. */ -function isArray(val) { +function isArray (val) { return objToString.call(val) === '[object Array]'; } @@ -220,7 +228,7 @@ function isArray(val) { * * @api public */ -function EventEmitter() {} +function EventEmitter () {} /** * Add a listener. @@ -230,7 +238,7 @@ function EventEmitter() {} * @param {Function} fn Event handler. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.on = function(name, fn) { +EventEmitter.prototype.on = function (name, fn) { if (!this.$events) { this.$events = {}; } @@ -256,10 +264,10 @@ EventEmitter.prototype.addListener = EventEmitter.prototype.on; * @param {Function} fn Event handler. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.once = function(name, fn) { +EventEmitter.prototype.once = function (name, fn) { var self = this; - function on() { + function on () { self.removeListener(name, on); fn.apply(this, arguments); } @@ -278,7 +286,7 @@ EventEmitter.prototype.once = function(name, fn) { * @param {Function} fn Event handler. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.removeListener = function(name, fn) { +EventEmitter.prototype.removeListener = function (name, fn) { if (this.$events && this.$events[name]) { var list = this.$events[name]; @@ -316,7 +324,7 @@ EventEmitter.prototype.removeListener = function(name, fn) { * @param {string} name Event name. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.removeAllListeners = function(name) { +EventEmitter.prototype.removeAllListeners = function (name) { if (name === undefined) { this.$events = {}; return this; @@ -336,7 +344,7 @@ EventEmitter.prototype.removeAllListeners = function(name) { * @param {string} name Event name. * @return {EventEmitter} Emitter instance. */ -EventEmitter.prototype.listeners = function(name) { +EventEmitter.prototype.listeners = function (name) { if (!this.$events) { this.$events = {}; } @@ -359,7 +367,7 @@ EventEmitter.prototype.listeners = function(name) { * @param {string} name Event name. * @return {boolean} true if at least one handler was invoked, else false. */ -EventEmitter.prototype.emit = function(name) { +EventEmitter.prototype.emit = function (name) { if (!this.$events) { return false; } @@ -388,6 +396,8 @@ EventEmitter.prototype.emit = function(name) { }; },{}],4:[function(require,module,exports){ +'use strict'; + /** * Expose `Progress`. */ @@ -397,7 +407,7 @@ module.exports = Progress; /** * Initialize a new `Progress` indicator. */ -function Progress() { +function Progress () { this.percent = 0; this.size(0); this.fontSize(11); @@ -411,7 +421,7 @@ function Progress() { * @param {number} size * @return {Progress} Progress instance. */ -Progress.prototype.size = function(size) { +Progress.prototype.size = function (size) { this._size = size; return this; }; @@ -423,7 +433,7 @@ Progress.prototype.size = function(size) { * @param {string} text * @return {Progress} Progress instance. */ -Progress.prototype.text = function(text) { +Progress.prototype.text = function (text) { this._text = text; return this; }; @@ -435,7 +445,7 @@ Progress.prototype.text = function(text) { * @param {number} size * @return {Progress} Progress instance. */ -Progress.prototype.fontSize = function(size) { +Progress.prototype.fontSize = function (size) { this._fontSize = size; return this; }; @@ -446,7 +456,7 @@ Progress.prototype.fontSize = function(size) { * @param {string} family * @return {Progress} Progress instance. */ -Progress.prototype.font = function(family) { +Progress.prototype.font = function (family) { this._font = family; return this; }; @@ -457,7 +467,7 @@ Progress.prototype.font = function(family) { * @param {number} n * @return {Progress} Progress instance. */ -Progress.prototype.update = function(n) { +Progress.prototype.update = function (n) { this.percent = n; return this; }; @@ -468,7 +478,7 @@ Progress.prototype.update = function(n) { * @param {CanvasRenderingContext2d} ctx * @return {Progress} Progress instance. */ -Progress.prototype.draw = function(ctx) { +Progress.prototype.draw = function (ctx) { try { var percent = Math.min(this.percent, 100); var size = this._size; @@ -508,11 +518,13 @@ Progress.prototype.draw = function(ctx) { },{}],5:[function(require,module,exports){ (function (global){ -exports.isatty = function isatty() { +'use strict'; + +exports.isatty = function isatty () { return true; }; -exports.getWindowSize = function getWindowSize() { +exports.getWindowSize = function getWindowSize () { if ('innerHeight' in global) { return [global.innerHeight, global.innerWidth]; } @@ -522,6 +534,8 @@ exports.getWindowSize = function getWindowSize() { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],6:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -539,7 +553,7 @@ module.exports = Context; * * @api private */ -function Context() {} +function Context () {} /** * Set or get the context `Runnable` to `runnable`. @@ -548,7 +562,7 @@ function Context() {} * @param {Runnable} runnable * @return {Context} */ -Context.prototype.runnable = function(runnable) { +Context.prototype.runnable = function (runnable) { if (!arguments.length) { return this._runnable; } @@ -563,7 +577,7 @@ Context.prototype.runnable = function(runnable) { * @param {number} ms * @return {Context} self */ -Context.prototype.timeout = function(ms) { +Context.prototype.timeout = function (ms) { if (!arguments.length) { return this.runnable().timeout(); } @@ -578,7 +592,7 @@ Context.prototype.timeout = function(ms) { * @param {boolean} enabled * @return {Context} self */ -Context.prototype.enableTimeouts = function(enabled) { +Context.prototype.enableTimeouts = function (enabled) { this.runnable().enableTimeouts(enabled); return this; }; @@ -590,7 +604,7 @@ Context.prototype.enableTimeouts = function(enabled) { * @param {number} ms * @return {Context} self */ -Context.prototype.slow = function(ms) { +Context.prototype.slow = function (ms) { this.runnable().slow(ms); return this; }; @@ -601,7 +615,7 @@ Context.prototype.slow = function(ms) { * @api private * @return {Context} self */ -Context.prototype.skip = function() { +Context.prototype.skip = function () { this.runnable().skip(); return this; }; @@ -613,7 +627,7 @@ Context.prototype.skip = function() { * @param {number} n * @return {Context} self */ -Context.prototype.retries = function(n) { +Context.prototype.retries = function (n) { if (!arguments.length) { return this.runnable().retries(); } @@ -627,13 +641,15 @@ Context.prototype.retries = function(n) { * @api private * @return {string} */ -Context.prototype.inspect = function() { - return JSON.stringify(this, function(key, val) { +Context.prototype.inspect = function () { + return JSON.stringify(this, function (key, val) { return key === 'runnable' || key === 'test' ? undefined : val; }, 2); }; },{"json3":54}],7:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -654,7 +670,7 @@ module.exports = Hook; * @param {Function} fn * @api private */ -function Hook(title, fn) { +function Hook (title, fn) { Runnable.call(this, title, fn); this.type = 'hook'; } @@ -671,7 +687,7 @@ inherits(Hook, Runnable); * @return {Error} * @api public */ -Hook.prototype.error = function(err) { +Hook.prototype.error = function (err) { if (!arguments.length) { err = this._error; this._error = null; @@ -682,6 +698,8 @@ Hook.prototype.error = function(err) { }; },{"./runnable":33,"./utils":38}],8:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -705,10 +723,10 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.before = common.before; @@ -722,7 +740,7 @@ module.exports = function(suite) { * and/or tests. */ - context.describe = context.context = function(title, fn) { + context.describe = context.context = function (title, fn) { return common.suite.create({ title: title, file: file, @@ -734,7 +752,7 @@ module.exports = function(suite) { * Pending describe. */ - context.xdescribe = context.xcontext = context.describe.skip = function(title, fn) { + context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) { return common.suite.skip({ title: title, file: file, @@ -746,7 +764,7 @@ module.exports = function(suite) { * Exclusive suite. */ - context.describe.only = function(title, fn) { + context.describe.only = function (title, fn) { return common.suite.only({ title: title, file: file, @@ -760,7 +778,7 @@ module.exports = function(suite) { * acting as a thunk. */ - context.it = context.specify = function(title, fn) { + context.it = context.specify = function (title, fn) { var suite = suites[0]; if (suite.isPending()) { fn = null; @@ -775,7 +793,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.it.only = function(title, fn) { + context.it.only = function (title, fn) { return common.test.only(mocha, context.it(title, fn)); }; @@ -783,14 +801,14 @@ module.exports = function(suite) { * Pending test case. */ - context.xit = context.xspecify = context.it.skip = function(title) { + context.xit = context.xspecify = context.it.skip = function (title) { context.it(title); }; /** * Number of attempts to retry. */ - context.it.retries = function(n) { + context.it.retries = function (n) { context.retries(n); }; }); @@ -809,7 +827,7 @@ var Suite = require('../suite'); * @param {Mocha} mocha * @return {Object} An object containing common functions. */ -module.exports = function(suites, context, mocha) { +module.exports = function (suites, context, mocha) { return { /** * This is only present if flag --delay is passed into Mocha. It triggers @@ -818,8 +836,8 @@ module.exports = function(suites, context, mocha) { * @param {Suite} suite The root wuite. * @return {Function} A function which runs the root suite */ - runWithSuite: function runWithSuite(suite) { - return function run() { + runWithSuite: function runWithSuite (suite) { + return function run () { suite.run(); }; }, @@ -830,7 +848,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - before: function(name, fn) { + before: function (name, fn) { suites[0].beforeAll(name, fn); }, @@ -840,7 +858,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - after: function(name, fn) { + after: function (name, fn) { suites[0].afterAll(name, fn); }, @@ -850,7 +868,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - beforeEach: function(name, fn) { + beforeEach: function (name, fn) { suites[0].beforeEach(name, fn); }, @@ -860,7 +878,7 @@ module.exports = function(suites, context, mocha) { * @param {string} name * @param {Function} fn */ - afterEach: function(name, fn) { + afterEach: function (name, fn) { suites[0].afterEach(name, fn); }, @@ -872,7 +890,7 @@ module.exports = function(suites, context, mocha) { * @param {Object} opts * @returns {Suite} */ - only: function only(opts) { + only: function only (opts) { mocha.options.hasOnly = true; opts.isOnly = true; return this.create(opts); @@ -885,7 +903,7 @@ module.exports = function(suites, context, mocha) { * @param {Object} opts * @returns {Suite} */ - skip: function skip(opts) { + skip: function skip (opts) { opts.pending = true; return this.create(opts); }, @@ -900,7 +918,7 @@ module.exports = function(suites, context, mocha) { * @param {boolean} [opts.isOnly] Is Suite exclusive? * @returns {Suite} */ - create: function create(opts) { + create: function create (opts) { var suite = Suite.create(suites[0], opts.title); suite.pending = Boolean(opts.pending); suite.file = opts.file; @@ -929,7 +947,7 @@ module.exports = function(suites, context, mocha) { * @param {Function} test * @returns {*} */ - only: function(mocha, test) { + only: function (mocha, test) { test.parent._onlyTests = test.parent._onlyTests.concat(test); mocha.options.hasOnly = true; return test; @@ -940,7 +958,7 @@ module.exports = function(suites, context, mocha) { * * @param {string} title */ - skip: function(title) { + skip: function (title) { context.test(title); }, @@ -949,7 +967,7 @@ module.exports = function(suites, context, mocha) { * * @param {number} n */ - retries: function(n) { + retries: function (n) { context.retries(n); } } @@ -957,6 +975,8 @@ module.exports = function(suites, context, mocha) { }; },{"../suite":35}],10:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -981,12 +1001,12 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; suite.on('require', visit); - function visit(obj, file) { + function visit (obj, file) { var suite; for (var key in obj) { if (typeof obj[key] === 'function') { @@ -1020,12 +1040,16 @@ module.exports = function(suite) { }; },{"../suite":35,"../test":36}],11:[function(require,module,exports){ +'use strict'; + exports.bdd = require('./bdd'); exports.tdd = require('./tdd'); exports.qunit = require('./qunit'); exports.exports = require('./exports'); },{"./bdd":8,"./exports":10,"./qunit":12,"./tdd":13}],12:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -1057,10 +1081,10 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.before = common.before; @@ -1072,7 +1096,7 @@ module.exports = function(suite) { * Describe a "suite" with the given `title`. */ - context.suite = function(title) { + context.suite = function (title) { if (suites.length > 1) { suites.shift(); } @@ -1087,7 +1111,7 @@ module.exports = function(suite) { * Exclusive Suite. */ - context.suite.only = function(title) { + context.suite.only = function (title) { if (suites.length > 1) { suites.shift(); } @@ -1104,7 +1128,7 @@ module.exports = function(suite) { * acting as a thunk. */ - context.test = function(title, fn) { + context.test = function (title, fn) { var test = new Test(title, fn); test.file = file; suites[0].addTest(test); @@ -1115,7 +1139,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.test.only = function(title, fn) { + context.test.only = function (title, fn) { return common.test.only(mocha, context.test(title, fn)); }; @@ -1125,6 +1149,8 @@ module.exports = function(suite) { }; },{"../test":36,"./common":9}],13:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -1156,10 +1182,10 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.setup = common.beforeEach; @@ -1172,7 +1198,7 @@ module.exports = function(suite) { * Describe a "suite" with the given `title` and callback `fn` containing * nested suites and/or tests. */ - context.suite = function(title, fn) { + context.suite = function (title, fn) { return common.suite.create({ title: title, file: file, @@ -1183,7 +1209,7 @@ module.exports = function(suite) { /** * Pending suite. */ - context.suite.skip = function(title, fn) { + context.suite.skip = function (title, fn) { return common.suite.skip({ title: title, file: file, @@ -1194,7 +1220,7 @@ module.exports = function(suite) { /** * Exclusive test-case. */ - context.suite.only = function(title, fn) { + context.suite.only = function (title, fn) { return common.suite.only({ title: title, file: file, @@ -1206,7 +1232,7 @@ module.exports = function(suite) { * Describe a specification or test-case with the given `title` and * callback `fn` acting as a thunk. */ - context.test = function(title, fn) { + context.test = function (title, fn) { var suite = suites[0]; if (suite.isPending()) { fn = null; @@ -1221,7 +1247,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.test.only = function(title, fn) { + context.test.only = function (title, fn) { return common.test.only(mocha, context.test(title, fn)); }; @@ -1232,6 +1258,8 @@ module.exports = function(suite) { },{"../test":36,"./common":9}],14:[function(require,module,exports){ (function (process,global,__dirname){ +'use strict'; + /*! * mocha * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca> @@ -1283,7 +1311,7 @@ exports.Test = require('./test'); * @param {string} name * @return {string} */ -function image(name) { +function image (name) { return path.join(__dirname, '../images', name + '.png'); } @@ -1306,7 +1334,7 @@ function image(name) { * @param {Object} options * @api public */ -function Mocha(options) { +function Mocha (options) { options = options || {}; this.files = []; this.options = options; @@ -1341,7 +1369,7 @@ function Mocha(options) { * @api public * @param {boolean} [bail] */ -Mocha.prototype.bail = function(bail) { +Mocha.prototype.bail = function (bail) { if (!arguments.length) { bail = true; } @@ -1355,7 +1383,7 @@ Mocha.prototype.bail = function(bail) { * @api public * @param {string} file */ -Mocha.prototype.addFile = function(file) { +Mocha.prototype.addFile = function (file) { this.files.push(file); return this; }; @@ -1369,7 +1397,7 @@ Mocha.prototype.addFile = function(file) { * @param {string|Function} reporter name or constructor * @param {Object} reporterOptions optional options */ -Mocha.prototype.reporter = function(reporter, reporterOptions) { +Mocha.prototype.reporter = function (reporter, reporterOptions) { if (typeof reporter === 'function') { this._reporter = reporter; } else { @@ -1390,9 +1418,9 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) { } } if (!_reporter && reporter === 'teamcity') { - console.warn('The Teamcity reporter was moved to a package named ' - + 'mocha-teamcity-reporter ' - + '(https://npmjs.org/package/mocha-teamcity-reporter).'); + console.warn('The Teamcity reporter was moved to a package named ' + + 'mocha-teamcity-reporter ' + + '(https://npmjs.org/package/mocha-teamcity-reporter).'); } if (!_reporter) { throw new Error('invalid reporter "' + reporter + '"'); @@ -1409,7 +1437,7 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) { * @api public * @param {string} bdd */ -Mocha.prototype.ui = function(name) { +Mocha.prototype.ui = function (name) { name = name || 'bdd'; this._ui = exports.interfaces[name]; if (!this._ui) { @@ -1421,7 +1449,7 @@ Mocha.prototype.ui = function(name) { } this._ui = this._ui(this.suite); - this.suite.on('pre-require', function(context) { + this.suite.on('pre-require', function (context) { exports.afterEach = context.afterEach || context.teardown; exports.after = context.after || context.suiteTeardown; exports.beforeEach = context.beforeEach || context.setup; @@ -1445,10 +1473,10 @@ Mocha.prototype.ui = function(name) { * * @api private */ -Mocha.prototype.loadFiles = function(fn) { +Mocha.prototype.loadFiles = function (fn) { var self = this; var suite = this.suite; - this.files.forEach(function(file) { + this.files.forEach(function (file) { file = path.resolve(file); suite.emit('pre-require', global, file, self); suite.emit('require', require(file), file, self); @@ -1462,10 +1490,10 @@ Mocha.prototype.loadFiles = function(fn) { * * @api private */ -Mocha.prototype._growl = function(runner, reporter) { +Mocha.prototype._growl = function (runner, reporter) { var notify = require('growl'); - runner.on('end', function() { + runner.on('end', function () { var stats = reporter.stats; if (stats.failures) { var msg = stats.failures + ' of ' + runner.total + ' tests failed'; @@ -1487,7 +1515,7 @@ Mocha.prototype._growl = function(runner, reporter) { * @param str * @returns {Mocha} */ -Mocha.prototype.fgrep = function(str) { +Mocha.prototype.fgrep = function (str) { return this.grep(new RegExp(escapeRe(str))); }; @@ -1500,7 +1528,7 @@ Mocha.prototype.fgrep = function(str) { * @param {RegExp|string} re * @return {Mocha} */ -Mocha.prototype.grep = function(re) { +Mocha.prototype.grep = function (re) { if (utils.isString(re)) { // extract args if it's regex-like, i.e: [string, pattern, flag] var arg = re.match(/^\/(.*)\/(g|i|)$|.*/); @@ -1516,7 +1544,7 @@ Mocha.prototype.grep = function(re) { * @return {Mocha} * @api public */ -Mocha.prototype.invert = function() { +Mocha.prototype.invert = function () { this.options.invert = true; return this; }; @@ -1530,7 +1558,7 @@ Mocha.prototype.invert = function() { * @param {boolean} ignore * @return {Mocha} */ -Mocha.prototype.ignoreLeaks = function(ignore) { +Mocha.prototype.ignoreLeaks = function (ignore) { this.options.ignoreLeaks = Boolean(ignore); return this; }; @@ -1541,7 +1569,7 @@ Mocha.prototype.ignoreLeaks = function(ignore) { * @return {Mocha} * @api public */ -Mocha.prototype.checkLeaks = function() { +Mocha.prototype.checkLeaks = function () { this.options.ignoreLeaks = false; return this; }; @@ -1552,7 +1580,7 @@ Mocha.prototype.checkLeaks = function() { * @return {Mocha} * @api public */ -Mocha.prototype.fullTrace = function() { +Mocha.prototype.fullTrace = function () { this.options.fullStackTrace = true; return this; }; @@ -1563,7 +1591,7 @@ Mocha.prototype.fullTrace = function() { * @return {Mocha} * @api public */ -Mocha.prototype.growl = function() { +Mocha.prototype.growl = function () { this.options.growl = true; return this; }; @@ -1577,7 +1605,7 @@ Mocha.prototype.growl = function() { * @param {Array|string} globals * @return {Mocha} */ -Mocha.prototype.globals = function(globals) { +Mocha.prototype.globals = function (globals) { this.options.globals = (this.options.globals || []).concat(globals); return this; }; @@ -1591,7 +1619,7 @@ Mocha.prototype.globals = function(globals) { * @param {boolean} colors * @return {Mocha} */ -Mocha.prototype.useColors = function(colors) { +Mocha.prototype.useColors = function (colors) { if (colors !== undefined) { this.options.useColors = colors; } @@ -1607,7 +1635,7 @@ Mocha.prototype.useColors = function(colors) { * @param {boolean} inlineDiffs * @return {Mocha} */ -Mocha.prototype.useInlineDiffs = function(inlineDiffs) { +Mocha.prototype.useInlineDiffs = function (inlineDiffs) { this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs; return this; }; @@ -1621,7 +1649,7 @@ Mocha.prototype.useInlineDiffs = function(inlineDiffs) { * @param {number} timeout * @return {Mocha} */ -Mocha.prototype.timeout = function(timeout) { +Mocha.prototype.timeout = function (timeout) { this.suite.timeout(timeout); return this; }; @@ -1633,7 +1661,7 @@ Mocha.prototype.timeout = function(timeout) { * @return {Mocha} * @api public */ -Mocha.prototype.retries = function(n) { +Mocha.prototype.retries = function (n) { this.suite.retries(n); return this; }; @@ -1647,7 +1675,7 @@ Mocha.prototype.retries = function(n) { * @param {number} slow * @return {Mocha} */ -Mocha.prototype.slow = function(slow) { +Mocha.prototype.slow = function (slow) { this.suite.slow(slow); return this; }; @@ -1661,7 +1689,7 @@ Mocha.prototype.slow = function(slow) { * @param {boolean} enabled * @return {Mocha} */ -Mocha.prototype.enableTimeouts = function(enabled) { +Mocha.prototype.enableTimeouts = function (enabled) { this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true); return this; }; @@ -1672,7 +1700,7 @@ Mocha.prototype.enableTimeouts = function(enabled) { * @return {Mocha} * @api public */ -Mocha.prototype.asyncOnly = function() { +Mocha.prototype.asyncOnly = function () { this.options.asyncOnly = true; return this; }; @@ -1682,7 +1710,7 @@ Mocha.prototype.asyncOnly = function() { * * @api public */ -Mocha.prototype.noHighlighting = function() { +Mocha.prototype.noHighlighting = function () { this.options.noHighlighting = true; return this; }; @@ -1693,7 +1721,7 @@ Mocha.prototype.noHighlighting = function() { * @return {Mocha} * @api public */ -Mocha.prototype.allowUncaught = function() { +Mocha.prototype.allowUncaught = function () { this.options.allowUncaught = true; return this; }; @@ -1702,7 +1730,7 @@ Mocha.prototype.allowUncaught = function() { * Delay root suite execution. * @returns {Mocha} */ -Mocha.prototype.delay = function delay() { +Mocha.prototype.delay = function delay () { this.options.delay = true; return this; }; @@ -1714,7 +1742,7 @@ Mocha.prototype.delay = function delay() { * @param {Function} fn * @return {Runner} */ -Mocha.prototype.run = function(fn) { +Mocha.prototype.run = function (fn) { if (this.files.length) { this.loadFiles(); } @@ -1742,7 +1770,7 @@ Mocha.prototype.run = function(fn) { } exports.reporters.Base.inlineDiffs = options.useInlineDiffs; - function done(failures) { + function done (failures) { if (reporter.done) { reporter.done(failures, fn); } else { @@ -1755,6 +1783,8 @@ Mocha.prototype.run = function(fn) { }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/lib") },{"./context":6,"./hook":7,"./interfaces":11,"./reporters":21,"./runnable":33,"./runner":34,"./suite":35,"./test":36,"./utils":38,"_process":67,"escape-string-regexp":47,"growl":49,"path":42}],15:[function(require,module,exports){ +'use strict'; + /** * Helpers. */ @@ -1777,7 +1807,7 @@ var y = d * 365.25; * @param {Object} options * @return {string|number} */ -module.exports = function(val, options) { +module.exports = function (val, options) { options = options || {}; if (typeof val === 'string') { return parse(val); @@ -1793,7 +1823,7 @@ module.exports = function(val, options) { * @param {string} str * @return {number} */ -function parse(str) { +function parse (str) { var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str); if (!match) { return; @@ -1835,7 +1865,7 @@ function parse(str) { * @param {number} ms * @return {string} */ -function shortFormat(ms) { +function shortFormat (ms) { if (ms >= d) { return Math.round(ms / d) + 'd'; } @@ -1858,12 +1888,12 @@ function shortFormat(ms) { * @param {number} ms * @return {string} */ -function longFormat(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; +function longFormat (ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms'; } /** @@ -1874,7 +1904,7 @@ function longFormat(ms) { * @param {number} n * @param {string} name */ -function plural(ms, n, name) { +function plural (ms, n, name) { if (ms < n) { return; } @@ -1885,6 +1915,7 @@ function plural(ms, n, name) { } },{}],16:[function(require,module,exports){ +'use strict'; /** * Expose `Pending`. @@ -1897,12 +1928,14 @@ module.exports = Pending; * * @param {string} message */ -function Pending(message) { +function Pending (message) { this.message = message; } },{}],17:[function(require,module,exports){ (function (process,global){ +'use strict'; + /** * Module dependencies. */ @@ -2006,7 +2039,7 @@ if (process.platform === 'win32') { * @return {string} * @api private */ -var color = exports.color = function(type, str) { +var color = exports.color = function (type, str) { if (!exports.useColors) { return String(str); } @@ -2032,23 +2065,23 @@ if (isatty) { */ exports.cursor = { - hide: function() { + hide: function () { isatty && process.stdout.write('\u001b[?25l'); }, - show: function() { + show: function () { isatty && process.stdout.write('\u001b[?25h'); }, - deleteLine: function() { + deleteLine: function () { isatty && process.stdout.write('\u001b[2K'); }, - beginningOfLine: function() { + beginningOfLine: function () { isatty && process.stdout.write('\u001b[0G'); }, - CR: function() { + CR: function () { if (isatty) { exports.cursor.deleteLine(); exports.cursor.beginningOfLine(); @@ -2065,13 +2098,13 @@ exports.cursor = { * @api public */ -exports.list = function(failures) { +exports.list = function (failures) { console.log(); - failures.forEach(function(test, i) { + failures.forEach(function (test, i) { // format - var fmt = color('error title', ' %s) %s:\n') - + color('error message', ' %s') - + color('error stack', '\n%s\n'); + var fmt = color('error title', ' %s) %s:\n') + + color('error message', ' %s') + + color('error stack', '\n%s\n'); // msg var msg; @@ -2141,7 +2174,7 @@ exports.list = function(failures) { * @api public */ -function Base(runner) { +function Base (runner) { var stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }; var failures = this.failures = []; @@ -2152,21 +2185,21 @@ function Base(runner) { runner.stats = stats; - runner.on('start', function() { + runner.on('start', function () { stats.start = new Date(); }); - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { stats.suites = stats.suites || 0; suite.root || stats.suites++; }); - runner.on('test end', function() { + runner.on('test end', function () { stats.tests = stats.tests || 0; stats.tests++; }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { stats.passes = stats.passes || 0; if (test.duration > test.slow()) { @@ -2180,19 +2213,19 @@ function Base(runner) { stats.passes++; }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { stats.failures = stats.failures || 0; stats.failures++; test.err = err; failures.push(test); }); - runner.on('end', function() { + runner.on('end', function () { stats.end = new Date(); stats.duration = new Date() - stats.start; }); - runner.on('pending', function() { + runner.on('pending', function () { stats.pending++; }); } @@ -2203,16 +2236,16 @@ function Base(runner) { * * @api public */ -Base.prototype.epilogue = function() { +Base.prototype.epilogue = function () { var stats = this.stats; var fmt; console.log(); // passes - fmt = color('bright pass', ' ') - + color('green', ' %d passing') - + color('light', ' (%s)'); + fmt = color('bright pass', ' ') + + color('green', ' %d passing') + + color('light', ' (%s)'); console.log(fmt, stats.passes || 0, @@ -2220,8 +2253,8 @@ Base.prototype.epilogue = function() { // pending if (stats.pending) { - fmt = color('pending', ' ') - + color('pending', ' %d pending'); + fmt = color('pending', ' ') + + color('pending', ' %d pending'); console.log(fmt, stats.pending); } @@ -2247,7 +2280,7 @@ Base.prototype.epilogue = function() { * @param {string} len * @return {string} */ -function pad(str, len) { +function pad (str, len) { str = String(str); return Array(len - str.length + 1).join(' ') + str; } @@ -2260,26 +2293,26 @@ function pad(str, len) { * @param {boolean} escape * @return {string} Diff */ -function inlineDiff(err, escape) { +function inlineDiff (err, escape) { var msg = errorDiff(err, 'WordsWithSpace', escape); // linenos var lines = msg.split('\n'); if (lines.length > 4) { var width = String(lines.length).length; - msg = lines.map(function(str, i) { + msg = lines.map(function (str, i) { return pad(++i, width) + ' |' + ' ' + str; }).join('\n'); } // legend - msg = '\n' - + color('diff removed', 'actual') - + ' ' - + color('diff added', 'expected') - + '\n\n' - + msg - + '\n'; + msg = '\n' + + color('diff removed', 'actual') + + ' ' + + color('diff added', 'expected') + + '\n\n' + + msg + + '\n'; // indent msg = msg.replace(/^/gm, ' '); @@ -2294,9 +2327,9 @@ function inlineDiff(err, escape) { * @param {boolean} escape * @return {string} The diff. */ -function unifiedDiff(err, escape) { +function unifiedDiff (err, escape) { var indent = ' '; - function cleanUp(line) { + function cleanUp (line) { if (escape) { line = escapeInvisibles(line); } @@ -2306,7 +2339,7 @@ function unifiedDiff(err, escape) { if (line[0] === '-') { return indent + colorLines('diff removed', line); } - if (line.match(/\@\@/)) { + if (line.match(/@@/)) { return null; } if (line.match(/\\ No newline/)) { @@ -2314,16 +2347,16 @@ function unifiedDiff(err, escape) { } return indent + line; } - function notBlank(line) { + function notBlank (line) { return typeof line !== 'undefined' && line !== null; } var msg = diff.createPatch('string', err.actual, err.expected); var lines = msg.split('\n').splice(4); - return '\n ' - + colorLines('diff added', '+ expected') + ' ' - + colorLines('diff removed', '- actual') - + '\n\n' - + lines.map(cleanUp).filter(notBlank).join('\n'); + return '\n ' + + colorLines('diff added', '+ expected') + ' ' + + colorLines('diff removed', '- actual') + + '\n\n' + + lines.map(cleanUp).filter(notBlank).join('\n'); } /** @@ -2335,10 +2368,10 @@ function unifiedDiff(err, escape) { * @param {boolean} escape * @return {string} */ -function errorDiff(err, type, escape) { +function errorDiff (err, type, escape) { var actual = escape ? escapeInvisibles(err.actual) : err.actual; var expected = escape ? escapeInvisibles(err.expected) : err.expected; - return diff['diff' + type](actual, expected).map(function(str) { + return diff['diff' + type](actual, expected).map(function (str) { if (str.added) { return colorLines('diff added', str.value); } @@ -2356,7 +2389,7 @@ function errorDiff(err, type, escape) { * @param {string} line * @return {string} */ -function escapeInvisibles(line) { +function escapeInvisibles (line) { return line.replace(/\t/g, '<tab>') .replace(/\r/g, '<CR>') .replace(/\n/g, '<LF>\n'); @@ -2370,8 +2403,8 @@ function escapeInvisibles(line) { * @param {string} str * @return {string} */ -function colorLines(name, str) { - return str.split('\n').map(function(str) { +function colorLines (name, str) { + return str.split('\n').map(function (str) { return color(name, str); }).join('\n'); } @@ -2389,12 +2422,14 @@ var objToString = Object.prototype.toString; * @param {Object} b * @return {boolean} */ -function sameType(a, b) { +function sameType (a, b) { return objToString.call(a) === objToString.call(b); } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"../ms":15,"../utils":38,"_process":67,"diff":46,"supports-color":42,"tty":5}],18:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -2414,16 +2449,16 @@ exports = module.exports = Doc; * @param {Runner} runner * @api public */ -function Doc(runner) { +function Doc (runner) { Base.call(this, runner); var indents = 2; - function indent() { + function indent () { return Array(indents).join(' '); } - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { if (suite.root) { return; } @@ -2434,7 +2469,7 @@ function Doc(runner) { console.log('%s<dl>', indent()); }); - runner.on('suite end', function(suite) { + runner.on('suite end', function (suite) { if (suite.root) { return; } @@ -2444,13 +2479,13 @@ function Doc(runner) { --indents; }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title)); var code = utils.escape(utils.clean(test.body)); console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code); }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { console.log('%s <dt class="error">%s</dt>', indent(), utils.escape(test.title)); var code = utils.escape(utils.clean(test.body)); console.log('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(), code); @@ -2460,6 +2495,8 @@ function Doc(runner) { },{"../utils":38,"./base":17}],19:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -2480,25 +2517,25 @@ exports = module.exports = Dot; * @api public * @param {Runner} runner */ -function Dot(runner) { +function Dot (runner) { Base.call(this, runner); var self = this; - var width = Base.window.width * .75 | 0; + var width = Base.window.width * 0.75 | 0; var n = -1; - runner.on('start', function() { + runner.on('start', function () { process.stdout.write('\n'); }); - runner.on('pending', function() { + runner.on('pending', function () { if (++n % width === 0) { process.stdout.write('\n '); } process.stdout.write(color('pending', Base.symbols.comma)); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { if (++n % width === 0) { process.stdout.write('\n '); } @@ -2509,14 +2546,14 @@ function Dot(runner) { } }); - runner.on('fail', function() { + runner.on('fail', function () { if (++n % width === 0) { process.stdout.write('\n '); } process.stdout.write(color('fail', Base.symbols.bang)); }); - runner.on('end', function() { + runner.on('end', function () { console.log(); self.epilogue(); }); @@ -2530,6 +2567,8 @@ inherits(Dot, Base); }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],20:[function(require,module,exports){ (function (global){ +'use strict'; + /* eslint-env browser */ /** @@ -2564,12 +2603,12 @@ exports = module.exports = HTML; * Stats template. */ -var statsTemplate = '<ul id="mocha-stats">' - + '<li class="progress"><canvas width="40" height="40"></canvas></li>' - + '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' - + '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' - + '<li class="duration">duration: <em>0</em>s</li>' - + '</ul>'; +var statsTemplate = '<ul id="mocha-stats">' + + '<li class="progress"><canvas width="40" height="40"></canvas></li>' + + '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' + + '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' + + '<li class="duration">duration: <em>0</em>s</li>' + + '</ul>'; /** * Initialize a new `HTML` reporter. @@ -2577,7 +2616,7 @@ var statsTemplate = '<ul id="mocha-stats">' * @api public * @param {Runner} runner */ -function HTML(runner) { +function HTML (runner) { Base.call(this, runner); var self = this; @@ -2612,7 +2651,7 @@ function HTML(runner) { } // pass toggle - on(passesLink, 'click', function(evt) { + on(passesLink, 'click', function (evt) { evt.preventDefault(); unhide(); var name = (/pass/).test(report.className) ? '' : ' pass'; @@ -2623,7 +2662,7 @@ function HTML(runner) { }); // failure toggle - on(failuresLink, 'click', function(evt) { + on(failuresLink, 'click', function (evt) { evt.preventDefault(); unhide(); var name = (/fail/).test(report.className) ? '' : ' fail'; @@ -2640,7 +2679,7 @@ function HTML(runner) { progress.size(40); } - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { if (suite.root) { return; } @@ -2655,7 +2694,7 @@ function HTML(runner) { el.appendChild(stack[0]); }); - runner.on('suite end', function(suite) { + runner.on('suite end', function (suite) { if (suite.root) { updateStats(); return; @@ -2663,17 +2702,17 @@ function HTML(runner) { stack.shift(); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { var url = self.testURL(test); - var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' - + '<a href="%s" class="replay">‣</a></h2></li>'; + var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' + + '<a href="%s" class="replay">‣</a></h2></li>'; var el = fragment(markup, test.speed, test.title, test.duration, url); self.addCodeToggle(el, test.body); appendToStack(el); updateStats(); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">‣</a></h2></li>', test.title, self.testURL(test)); var stackString; // Note: Includes leading newline @@ -2713,20 +2752,20 @@ function HTML(runner) { updateStats(); }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title); appendToStack(el); updateStats(); }); - function appendToStack(el) { + function appendToStack (el) { // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack. if (stack[0]) { stack[0].appendChild(el); } } - function updateStats() { + function updateStats () { // TODO: add to stats var percent = stats.tests / runner.total * 100 | 0; if (progress) { @@ -2747,7 +2786,7 @@ function HTML(runner) { * @param {string} s * @return {string} A new URL. */ -function makeUrl(s) { +function makeUrl (s) { var search = window.location.search; // Remove previous grep query parameter if present @@ -2763,7 +2802,7 @@ function makeUrl(s) { * * @param {Object} [suite] */ -HTML.prototype.suiteURL = function(suite) { +HTML.prototype.suiteURL = function (suite) { return makeUrl(suite.fullTitle()); }; @@ -2772,7 +2811,7 @@ HTML.prototype.suiteURL = function(suite) { * * @param {Object} [test] */ -HTML.prototype.testURL = function(test) { +HTML.prototype.testURL = function (test) { return makeUrl(test.fullTitle()); }; @@ -2782,10 +2821,10 @@ HTML.prototype.testURL = function(test) { * @param {HTMLLIElement} el * @param {string} contents */ -HTML.prototype.addCodeToggle = function(el, contents) { +HTML.prototype.addCodeToggle = function (el, contents) { var h2 = el.getElementsByTagName('h2')[0]; - on(h2, 'click', function() { + on(h2, 'click', function () { pre.style.display = pre.style.display === 'none' ? 'block' : 'none'; }); @@ -2799,7 +2838,7 @@ HTML.prototype.addCodeToggle = function(el, contents) { * * @param {string} msg */ -function error(msg) { +function error (msg) { document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg)); } @@ -2808,12 +2847,12 @@ function error(msg) { * * @param {string} html */ -function fragment(html) { +function fragment (html) { var args = arguments; var div = document.createElement('div'); var i = 1; - div.innerHTML = html.replace(/%([se])/g, function(_, type) { + div.innerHTML = html.replace(/%([se])/g, function (_, type) { switch (type) { case 's': return String(args[i++]); case 'e': return escape(args[i++]); @@ -2830,7 +2869,7 @@ function fragment(html) { * * @param {text} classname */ -function hideSuitesWithout(classname) { +function hideSuitesWithout (classname) { var suites = document.getElementsByClassName('suite'); for (var i = 0; i < suites.length; i++) { var els = suites[i].getElementsByClassName(classname); @@ -2843,7 +2882,7 @@ function hideSuitesWithout(classname) { /** * Unhide .hidden suites. */ -function unhide() { +function unhide () { var els = document.getElementsByClassName('suite hidden'); for (var i = 0; i < els.length; ++i) { els[i].className = els[i].className.replace('suite hidden', 'suite'); @@ -2856,7 +2895,7 @@ function unhide() { * @param {HTMLElement} el * @param {string} contents */ -function text(el, contents) { +function text (el, contents) { if (el.textContent) { el.textContent = contents; } else { @@ -2867,7 +2906,7 @@ function text(el, contents) { /** * Listen on `event` with callback `fn`. */ -function on(el, event, fn) { +function on (el, event, fn) { if (el.addEventListener) { el.addEventListener(event, fn, false); } else { @@ -2877,6 +2916,8 @@ function on(el, event, fn) { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"../browser/progress":4,"../utils":38,"./base":17,"escape-string-regexp":47}],21:[function(require,module,exports){ +'use strict'; + // Alias exports to a their normalized format Mocha#reporter to prevent a need // for dynamic (try/catch) requires, which Browserify doesn't handle. exports.Base = exports.base = require('./base'); @@ -2897,6 +2938,8 @@ exports.JSONStream = exports['json-stream'] = require('./json-stream'); },{"./base":17,"./doc":18,"./dot":19,"./html":20,"./json":23,"./json-stream":22,"./landing":24,"./list":25,"./markdown":26,"./min":27,"./nyan":28,"./progress":29,"./spec":30,"./tap":31,"./xunit":32}],22:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -2916,28 +2959,28 @@ exports = module.exports = List; * @api public * @param {Runner} runner */ -function List(runner) { +function List (runner) { Base.call(this, runner); var self = this; var total = runner.total; - runner.on('start', function() { + runner.on('start', function () { console.log(JSON.stringify(['start', { total: total }])); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { console.log(JSON.stringify(['pass', clean(test)])); }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { test = clean(test); test.err = err.message; test.stack = err.stack || null; console.log(JSON.stringify(['fail', test])); }); - runner.on('end', function() { + runner.on('end', function () { process.stdout.write(JSON.stringify(['end', self.stats])); }); } @@ -2950,7 +2993,7 @@ function List(runner) { * @param {Object} test * @return {Object} */ -function clean(test) { +function clean (test) { return { title: test.title, fullTitle: test.fullTitle(), @@ -2962,6 +3005,8 @@ function clean(test) { }).call(this,require('_process')) },{"./base":17,"_process":67,"json3":54}],23:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -2980,7 +3025,7 @@ exports = module.exports = JSONReporter; * @api public * @param {Runner} runner */ -function JSONReporter(runner) { +function JSONReporter (runner) { Base.call(this, runner); var self = this; @@ -2989,23 +3034,23 @@ function JSONReporter(runner) { var failures = []; var passes = []; - runner.on('test end', function(test) { + runner.on('test end', function (test) { tests.push(test); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { passes.push(test); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { failures.push(test); }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { pending.push(test); }); - runner.on('end', function() { + runner.on('end', function () { var obj = { stats: self.stats, tests: tests.map(clean), @@ -3028,7 +3073,7 @@ function JSONReporter(runner) { * @param {Object} test * @return {Object} */ -function clean(test) { +function clean (test) { return { title: test.title, fullTitle: test.fullTitle(), @@ -3045,9 +3090,9 @@ function clean(test) { * @param {Error} err * @return {Object} */ -function errorJSON(err) { +function errorJSON (err) { var res = {}; - Object.getOwnPropertyNames(err).forEach(function(key) { + Object.getOwnPropertyNames(err).forEach(function (key) { res[key] = err[key]; }, err); return res; @@ -3056,6 +3101,8 @@ function errorJSON(err) { }).call(this,require('_process')) },{"./base":17,"_process":67}],24:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -3095,28 +3142,28 @@ Base.colors.runway = 90; * @api public * @param {Runner} runner */ -function Landing(runner) { +function Landing (runner) { Base.call(this, runner); var self = this; - var width = Base.window.width * .75 | 0; + var width = Base.window.width * 0.75 | 0; var total = runner.total; var stream = process.stdout; var plane = color('plane', '✈'); var crashed = -1; var n = 0; - function runway() { + function runway () { var buf = Array(width).join('-'); return ' ' + color('runway', buf); } - runner.on('start', function() { + runner.on('start', function () { stream.write('\n\n\n '); cursor.hide(); }); - runner.on('test end', function(test) { + runner.on('test end', function (test) { // check if the plane crashed var col = crashed === -1 ? width * ++n / total | 0 : crashed; @@ -3137,7 +3184,7 @@ function Landing(runner) { stream.write('\u001b[0m'); }); - runner.on('end', function() { + runner.on('end', function () { cursor.show(); console.log(); self.epilogue(); @@ -3152,6 +3199,8 @@ inherits(Landing, Base); }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],25:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -3173,35 +3222,35 @@ exports = module.exports = List; * @api public * @param {Runner} runner */ -function List(runner) { +function List (runner) { Base.call(this, runner); var self = this; var n = 0; - runner.on('start', function() { + runner.on('start', function () { console.log(); }); - runner.on('test', function(test) { + runner.on('test', function (test) { process.stdout.write(color('pass', ' ' + test.fullTitle() + ': ')); }); - runner.on('pending', function(test) { - var fmt = color('checkmark', ' -') - + color('pending', ' %s'); + runner.on('pending', function (test) { + var fmt = color('checkmark', ' -') + + color('pending', ' %s'); console.log(fmt, test.fullTitle()); }); - runner.on('pass', function(test) { - var fmt = color('checkmark', ' ' + Base.symbols.dot) - + color('pass', ' %s: ') - + color(test.speed, '%dms'); + runner.on('pass', function (test) { + var fmt = color('checkmark', ' ' + Base.symbols.dot) + + color('pass', ' %s: ') + + color(test.speed, '%dms'); cursor.CR(); console.log(fmt, test.fullTitle(), test.duration); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { cursor.CR(); console.log(color('fail', ' %d) %s'), ++n, test.fullTitle()); }); @@ -3217,6 +3266,8 @@ inherits(List, Base); }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],26:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -3242,29 +3293,29 @@ exports = module.exports = Markdown; * @api public * @param {Runner} runner */ -function Markdown(runner) { +function Markdown (runner) { Base.call(this, runner); var level = 0; var buf = ''; - function title(str) { + function title (str) { return Array(level).join('#') + ' ' + str; } - function mapTOC(suite, obj) { + function mapTOC (suite, obj) { var ret = obj; var key = SUITE_PREFIX + suite.title; obj = obj[key] = obj[key] || { suite: suite }; - suite.suites.forEach(function(suite) { + suite.suites.forEach(function (suite) { mapTOC(suite, obj); }); return ret; } - function stringifyTOC(obj, level) { + function stringifyTOC (obj, level) { ++level; var buf = ''; var link; @@ -3282,25 +3333,25 @@ function Markdown(runner) { return buf; } - function generateTOC(suite) { + function generateTOC (suite) { var obj = mapTOC(suite, {}); return stringifyTOC(obj, 0); } generateTOC(runner.suite); - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { ++level; var slug = utils.slug(suite.fullTitle()); buf += '<a name="' + slug + '"></a>' + '\n'; buf += title(suite.title) + '\n'; }); - runner.on('suite end', function() { + runner.on('suite end', function () { --level; }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { var code = utils.clean(test.body); buf += test.title + '.\n'; buf += '\n```js\n'; @@ -3308,7 +3359,7 @@ function Markdown(runner) { buf += '```\n\n'; }); - runner.on('end', function() { + runner.on('end', function () { process.stdout.write('# TOC\n'); process.stdout.write(generateTOC(runner.suite)); process.stdout.write(buf); @@ -3318,6 +3369,8 @@ function Markdown(runner) { }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],27:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -3337,10 +3390,10 @@ exports = module.exports = Min; * @api public * @param {Runner} runner */ -function Min(runner) { +function Min (runner) { Base.call(this, runner); - runner.on('start', function() { + runner.on('start', function () { // clear screen process.stdout.write('\u001b[2J'); // set cursor position @@ -3358,6 +3411,8 @@ inherits(Min, Base); }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],28:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -3378,11 +3433,11 @@ exports = module.exports = NyanCat; * @api public */ -function NyanCat(runner) { +function NyanCat (runner) { Base.call(this, runner); var self = this; - var width = Base.window.width * .75 | 0; + var width = Base.window.width * 0.75 | 0; var nyanCatWidth = this.nyanCatWidth = 11; this.colorIndex = 0; @@ -3393,24 +3448,24 @@ function NyanCat(runner) { this.trajectories = [[], [], [], []]; this.trajectoryWidthMax = (width - nyanCatWidth); - runner.on('start', function() { + runner.on('start', function () { Base.cursor.hide(); self.draw(); }); - runner.on('pending', function() { + runner.on('pending', function () { self.draw(); }); - runner.on('pass', function() { + runner.on('pass', function () { self.draw(); }); - runner.on('fail', function() { + runner.on('fail', function () { self.draw(); }); - runner.on('end', function() { + runner.on('end', function () { Base.cursor.show(); for (var i = 0; i < self.numberOfLines; i++) { write('\n'); @@ -3430,7 +3485,7 @@ inherits(NyanCat, Base); * @api private */ -NyanCat.prototype.draw = function() { +NyanCat.prototype.draw = function () { this.appendRainbow(); this.drawScoreboard(); this.drawRainbow(); @@ -3445,10 +3500,10 @@ NyanCat.prototype.draw = function() { * @api private */ -NyanCat.prototype.drawScoreboard = function() { +NyanCat.prototype.drawScoreboard = function () { var stats = this.stats; - function draw(type, n) { + function draw (type, n) { write(' '); write(Base.color(type, n)); write('\n'); @@ -3468,7 +3523,7 @@ NyanCat.prototype.drawScoreboard = function() { * @api private */ -NyanCat.prototype.appendRainbow = function() { +NyanCat.prototype.appendRainbow = function () { var segment = this.tick ? '_' : '-'; var rainbowified = this.rainbowify(segment); @@ -3487,10 +3542,10 @@ NyanCat.prototype.appendRainbow = function() { * @api private */ -NyanCat.prototype.drawRainbow = function() { +NyanCat.prototype.drawRainbow = function () { var self = this; - this.trajectories.forEach(function(line) { + this.trajectories.forEach(function (line) { write('\u001b[' + self.scoreboardWidth + 'C'); write(line.join('')); write('\n'); @@ -3504,7 +3559,7 @@ NyanCat.prototype.drawRainbow = function() { * * @api private */ -NyanCat.prototype.drawNyanCat = function() { +NyanCat.prototype.drawNyanCat = function () { var self = this; var startWidth = this.scoreboardWidth + this.trajectories[0].length; var dist = '\u001b[' + startWidth + 'C'; @@ -3540,7 +3595,7 @@ NyanCat.prototype.drawNyanCat = function() { * @return {string} */ -NyanCat.prototype.face = function() { +NyanCat.prototype.face = function () { var stats = this.stats; if (stats.failures) { return '( x .x)'; @@ -3559,7 +3614,7 @@ NyanCat.prototype.face = function() { * @param {number} n */ -NyanCat.prototype.cursorUp = function(n) { +NyanCat.prototype.cursorUp = function (n) { write('\u001b[' + n + 'A'); }; @@ -3570,7 +3625,7 @@ NyanCat.prototype.cursorUp = function(n) { * @param {number} n */ -NyanCat.prototype.cursorDown = function(n) { +NyanCat.prototype.cursorDown = function (n) { write('\u001b[' + n + 'B'); }; @@ -3580,7 +3635,7 @@ NyanCat.prototype.cursorDown = function(n) { * @api private * @return {Array} */ -NyanCat.prototype.generateColors = function() { +NyanCat.prototype.generateColors = function () { var colors = []; for (var i = 0; i < (6 * 7); i++) { @@ -3602,7 +3657,7 @@ NyanCat.prototype.generateColors = function() { * @param {string} str * @return {string} */ -NyanCat.prototype.rainbowify = function(str) { +NyanCat.prototype.rainbowify = function (str) { if (!Base.useColors) { return str; } @@ -3616,13 +3671,15 @@ NyanCat.prototype.rainbowify = function(str) { * * @param {string} string A message to write to stdout. */ -function write(string) { +function write (string) { process.stdout.write(string); } }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],29:[function(require,module,exports){ (function (process){ +'use strict'; + /** * Module dependencies. */ @@ -3651,11 +3708,11 @@ Base.colors.progress = 90; * @param {Runner} runner * @param {Object} options */ -function Progress(runner, options) { +function Progress (runner, options) { Base.call(this, runner); var self = this; - var width = Base.window.width * .50 | 0; + var width = Base.window.width * 0.50 | 0; var total = runner.total; var complete = 0; var lastN = -1; @@ -3669,13 +3726,13 @@ function Progress(runner, options) { options.verbose = false; // tests started - runner.on('start', function() { + runner.on('start', function () { console.log(); cursor.hide(); }); // tests complete - runner.on('test end', function() { + runner.on('test end', function () { complete++; var percent = complete / total; @@ -3701,7 +3758,7 @@ function Progress(runner, options) { // tests are complete, output some stats // and the failures if any - runner.on('end', function() { + runner.on('end', function () { cursor.show(); console.log(); self.epilogue(); @@ -3715,6 +3772,8 @@ inherits(Progress, Base); }).call(this,require('_process')) },{"../utils":38,"./base":17,"_process":67}],30:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -3735,55 +3794,55 @@ exports = module.exports = Spec; * @api public * @param {Runner} runner */ -function Spec(runner) { +function Spec (runner) { Base.call(this, runner); var self = this; var indents = 0; var n = 0; - function indent() { + function indent () { return Array(indents).join(' '); } - runner.on('start', function() { + runner.on('start', function () { console.log(); }); - runner.on('suite', function(suite) { + runner.on('suite', function (suite) { ++indents; console.log(color('suite', '%s%s'), indent(), suite.title); }); - runner.on('suite end', function() { + runner.on('suite end', function () { --indents; if (indents === 1) { console.log(); } }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { var fmt = indent() + color('pending', ' - %s'); console.log(fmt, test.title); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { var fmt; if (test.speed === 'fast') { - fmt = indent() - + color('checkmark', ' ' + Base.symbols.ok) - + color('pass', ' %s'); + fmt = indent() + + color('checkmark', ' ' + Base.symbols.ok) + + color('pass', ' %s'); console.log(fmt, test.title); } else { - fmt = indent() - + color('checkmark', ' ' + Base.symbols.ok) - + color('pass', ' %s') - + color(test.speed, ' (%dms)'); + fmt = indent() + + color('checkmark', ' ' + Base.symbols.ok) + + color('pass', ' %s') + + color(test.speed, ' (%dms)'); console.log(fmt, test.title, test.duration); } }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { console.log(indent() + color('fail', ' %d) %s'), ++n, test.title); }); @@ -3796,6 +3855,8 @@ function Spec(runner) { inherits(Spec, Base); },{"../utils":38,"./base":17}],31:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -3814,32 +3875,32 @@ exports = module.exports = TAP; * @api public * @param {Runner} runner */ -function TAP(runner) { +function TAP (runner) { Base.call(this, runner); var n = 1; var passes = 0; var failures = 0; - runner.on('start', function() { + runner.on('start', function () { var total = runner.grepTotal(runner.suite); console.log('%d..%d', 1, total); }); - runner.on('test end', function() { + runner.on('test end', function () { ++n; }); - runner.on('pending', function(test) { + runner.on('pending', function (test) { console.log('ok %d %s # SKIP -', n, title(test)); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { passes++; console.log('ok %d %s', n, title(test)); }); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { failures++; console.log('not ok %d %s', n, title(test)); if (err.stack) { @@ -3847,7 +3908,7 @@ function TAP(runner) { } }); - runner.on('end', function() { + runner.on('end', function () { console.log('# tests ' + (passes + failures)); console.log('# pass ' + passes); console.log('# fail ' + failures); @@ -3861,12 +3922,14 @@ function TAP(runner) { * @param {Object} test * @return {String} */ -function title(test) { +function title (test) { return test.fullTitle().replace(/#/g, ''); } },{"./base":17}],32:[function(require,module,exports){ (function (process,global){ +'use strict'; + /** * Module dependencies. */ @@ -3903,7 +3966,7 @@ exports = module.exports = XUnit; * @api public * @param {Runner} runner */ -function XUnit(runner, options) { +function XUnit (runner, options) { Base.call(this, runner); var stats = this.stats; @@ -3918,19 +3981,19 @@ function XUnit(runner, options) { self.fileStream = fs.createWriteStream(options.reporterOptions.output); } - runner.on('pending', function(test) { + runner.on('pending', function (test) { tests.push(test); }); - runner.on('pass', function(test) { + runner.on('pass', function (test) { tests.push(test); }); - runner.on('fail', function(test) { + runner.on('fail', function (test) { tests.push(test); }); - runner.on('end', function() { + runner.on('end', function () { self.write(tag('testsuite', { name: 'Mocha Tests', tests: stats.tests, @@ -3941,7 +4004,7 @@ function XUnit(runner, options) { time: (stats.duration / 1000) || 0 }, false)); - tests.forEach(function(t) { + tests.forEach(function (t) { self.test(t); }); @@ -3960,9 +4023,9 @@ inherits(XUnit, Base); * @param failures * @param {Function} fn */ -XUnit.prototype.done = function(failures, fn) { +XUnit.prototype.done = function (failures, fn) { if (this.fileStream) { - this.fileStream.end(function() { + this.fileStream.end(function () { fn(failures); }); } else { @@ -3975,7 +4038,7 @@ XUnit.prototype.done = function(failures, fn) { * * @param {string} line */ -XUnit.prototype.write = function(line) { +XUnit.prototype.write = function (line) { if (this.fileStream) { this.fileStream.write(line + '\n'); } else if (typeof process === 'object' && process.stdout) { @@ -3990,7 +4053,7 @@ XUnit.prototype.write = function(line) { * * @param {Test} test */ -XUnit.prototype.test = function(test) { +XUnit.prototype.test = function (test) { var attrs = { classname: test.parent.fullTitle(), name: test.title, @@ -4016,7 +4079,7 @@ XUnit.prototype.test = function(test) { * @param content * @return {string} */ -function tag(name, attrs, close, content) { +function tag (name, attrs, close, content) { var end = close ? '/>' : '>'; var pairs = []; var tag; @@ -4037,6 +4100,8 @@ function tag(name, attrs, close, content) { }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"../utils":38,"./base":17,"_process":67,"fs":42,"mkdirp":64,"path":42}],33:[function(require,module,exports){ (function (global){ +'use strict'; + /** * Module dependencies. */ @@ -4082,7 +4147,7 @@ module.exports = Runnable; * @param {string} title * @param {Function} fn */ -function Runnable(title, fn) { +function Runnable (title, fn) { this.title = title; this.fn = fn; this.body = (fn || '').toString(); @@ -4112,7 +4177,7 @@ Runnable.prototype = create(EventEmitter.prototype, { * @param {number|string} ms * @return {Runnable|number} ms or Runnable instance. */ -Runnable.prototype.timeout = function(ms) { +Runnable.prototype.timeout = function (ms) { if (!arguments.length) { return this._timeout; } @@ -4138,7 +4203,7 @@ Runnable.prototype.timeout = function(ms) { * @param {number|string} ms * @return {Runnable|number} ms or Runnable instance. */ -Runnable.prototype.slow = function(ms) { +Runnable.prototype.slow = function (ms) { if (typeof ms === 'undefined') { return this._slow; } @@ -4157,7 +4222,7 @@ Runnable.prototype.slow = function(ms) { * @param {boolean} enabled * @return {Runnable|boolean} enabled or Runnable instance. */ -Runnable.prototype.enableTimeouts = function(enabled) { +Runnable.prototype.enableTimeouts = function (enabled) { if (!arguments.length) { return this._enableTimeouts; } @@ -4171,7 +4236,7 @@ Runnable.prototype.enableTimeouts = function(enabled) { * * @api public */ -Runnable.prototype.skip = function() { +Runnable.prototype.skip = function () { throw new Pending('sync skip'); }; @@ -4180,7 +4245,7 @@ Runnable.prototype.skip = function() { * * @api private */ -Runnable.prototype.isPending = function() { +Runnable.prototype.isPending = function () { return this.pending || (this.parent && this.parent.isPending()); }; @@ -4189,7 +4254,7 @@ Runnable.prototype.isPending = function() { * * @api private */ -Runnable.prototype.retries = function(n) { +Runnable.prototype.retries = function (n) { if (!arguments.length) { return this._retries; } @@ -4201,7 +4266,7 @@ Runnable.prototype.retries = function(n) { * * @api private */ -Runnable.prototype.currentRetry = function(n) { +Runnable.prototype.currentRetry = function (n) { if (!arguments.length) { return this._currentRetry; } @@ -4215,7 +4280,7 @@ Runnable.prototype.currentRetry = function(n) { * @api public * @return {string} */ -Runnable.prototype.fullTitle = function() { +Runnable.prototype.fullTitle = function () { return this.parent.fullTitle() + ' ' + this.title; }; @@ -4224,7 +4289,7 @@ Runnable.prototype.fullTitle = function() { * * @api private */ -Runnable.prototype.clearTimeout = function() { +Runnable.prototype.clearTimeout = function () { clearTimeout(this.timer); }; @@ -4234,8 +4299,8 @@ Runnable.prototype.clearTimeout = function() { * @api private * @return {string} */ -Runnable.prototype.inspect = function() { - return JSON.stringify(this, function(key, val) { +Runnable.prototype.inspect = function () { + return JSON.stringify(this, function (key, val) { if (key[0] === '_') { return; } @@ -4254,7 +4319,7 @@ Runnable.prototype.inspect = function() { * * @api private */ -Runnable.prototype.resetTimeout = function() { +Runnable.prototype.resetTimeout = function () { var self = this; var ms = this.timeout() || 1e9; @@ -4262,7 +4327,7 @@ Runnable.prototype.resetTimeout = function() { return; } this.clearTimeout(); - this.timer = setTimeout(function() { + this.timer = setTimeout(function () { if (!self._enableTimeouts) { return; } @@ -4277,7 +4342,7 @@ Runnable.prototype.resetTimeout = function() { * @api private * @param {string[]} globals */ -Runnable.prototype.globals = function(globals) { +Runnable.prototype.globals = function (globals) { if (!arguments.length) { return this._allowedGlobals; } @@ -4290,7 +4355,7 @@ Runnable.prototype.globals = function(globals) { * @param {Function} fn * @api private */ -Runnable.prototype.run = function(fn) { +Runnable.prototype.run = function (fn) { var self = this; var start = new Date(); var ctx = this.ctx; @@ -4303,7 +4368,7 @@ Runnable.prototype.run = function(fn) { } // called multiple times - function multiple(err) { + function multiple (err) { if (emitted) { return; } @@ -4312,7 +4377,7 @@ Runnable.prototype.run = function(fn) { } // finished - function done(err) { + function done (err) { var ms = self.timeout(); if (self.timedOut) { return; @@ -4338,7 +4403,7 @@ Runnable.prototype.run = function(fn) { this.resetTimeout(); // allows skip() to be used in an explicit async context - this.skip = function asyncSkip() { + this.skip = function asyncSkip () { done(new Pending('async skip call')); // halt execution. the Runnable will be marked pending // by the previous call, and the uncaught handler will ignore @@ -4352,6 +4417,7 @@ Runnable.prototype.run = function(fn) { try { callFnAsync(this.fn); } catch (err) { + emitted = true; done(utils.getError(err)); } return; @@ -4371,21 +4437,22 @@ Runnable.prototype.run = function(fn) { callFn(this.fn); } } catch (err) { + emitted = true; done(utils.getError(err)); } - function callFn(fn) { + function callFn (fn) { var result = fn.call(ctx); if (result && typeof result.then === 'function') { self.resetTimeout(); result - .then(function() { + .then(function () { done(); // Return null so libraries like bluebird do not warn about // subsequently constructed Promises. return null; }, - function(reason) { + function (reason) { done(reason || new Error('Promise rejected with no or falsy reason')); }); } else { @@ -4397,15 +4464,15 @@ Runnable.prototype.run = function(fn) { } } - function callFnAsync(fn) { - var result = fn.call(ctx, function(err) { + function callFnAsync (fn) { + var result = fn.call(ctx, function (err) { if (err instanceof Error || toString.call(err) === '[object Error]') { return done(err); } if (err) { if (Object.prototype.toString.call(err) === '[object Object]') { - return done(new Error('done() invoked with non-Error: ' - + JSON.stringify(err))); + return done(new Error('done() invoked with non-Error: ' + + JSON.stringify(err))); } return done(new Error('done() invoked with non-Error: ' + err)); } @@ -4421,6 +4488,8 @@ Runnable.prototype.run = function(fn) { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":54,"lodash.create":60}],34:[function(require,module,exports){ (function (process,global){ +'use strict'; + /** * Module dependencies. */ @@ -4484,7 +4553,7 @@ module.exports = Runner; * @param {boolean} [delay] Whether or not to delay execution of root suite * until ready. */ -function Runner(suite, delay) { +function Runner (suite, delay) { var self = this; this._globals = []; this._abort = false; @@ -4493,10 +4562,10 @@ function Runner(suite, delay) { this.started = false; this.total = suite.total(); this.failures = 0; - this.on('test end', function(test) { + this.on('test end', function (test) { self.checkGlobals(test); }); - this.on('hook end', function(hook) { + this.on('hook end', function (hook) { self.checkGlobals(hook); }); this._defaultGrep = /.*/; @@ -4529,7 +4598,7 @@ inherits(Runner, EventEmitter); * @param {boolean} invert * @return {Runner} Runner instance. */ -Runner.prototype.grep = function(re, invert) { +Runner.prototype.grep = function (re, invert) { debug('grep %s', re); this._grep = re; this._invert = invert; @@ -4547,11 +4616,11 @@ Runner.prototype.grep = function(re, invert) { * @param {Suite} suite * @return {number} */ -Runner.prototype.grepTotal = function(suite) { +Runner.prototype.grepTotal = function (suite) { var self = this; var total = 0; - suite.eachTest(function(test) { + suite.eachTest(function (test) { var match = self._grep.test(test.fullTitle()); if (self._invert) { match = !match; @@ -4570,7 +4639,7 @@ Runner.prototype.grepTotal = function(suite) { * @return {Array} * @api private */ -Runner.prototype.globalProps = function() { +Runner.prototype.globalProps = function () { var props = keys(global); // non-enumerables @@ -4593,7 +4662,7 @@ Runner.prototype.globalProps = function() { * @param {Array} arr * @return {Runner} Runner instance. */ -Runner.prototype.globals = function(arr) { +Runner.prototype.globals = function (arr) { if (!arguments.length) { return this._globals; } @@ -4607,7 +4676,7 @@ Runner.prototype.globals = function(arr) { * * @api private */ -Runner.prototype.checkGlobals = function(test) { +Runner.prototype.checkGlobals = function (test) { if (this.ignoreLeaks) { return; } @@ -4642,7 +4711,7 @@ Runner.prototype.checkGlobals = function(test) { * @param {Test} test * @param {Error} err */ -Runner.prototype.fail = function(test, err) { +Runner.prototype.fail = function (test, err) { if (test.isPending()) { return; } @@ -4654,9 +4723,13 @@ Runner.prototype.fail = function(test, err) { err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'); } - err.stack = (this.fullStackTrace || !err.stack) - ? err.stack - : stackFilter(err.stack); + try { + err.stack = (this.fullStackTrace || !err.stack) + ? err.stack + : stackFilter(err.stack); + } catch (ignored) { + // some environments do not take kindly to monkeying with the stack + } this.emit('fail', test, err); }; @@ -4681,7 +4754,7 @@ Runner.prototype.fail = function(test, err) { * @param {Hook} hook * @param {Error} err */ -Runner.prototype.failHook = function(hook, err) { +Runner.prototype.failHook = function (hook, err) { if (hook.ctx && hook.ctx.currentTest) { hook.originalTitle = hook.originalTitle || hook.title; hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"'; @@ -4701,12 +4774,12 @@ Runner.prototype.failHook = function(hook, err) { * @param {Function} fn */ -Runner.prototype.hook = function(name, fn) { +Runner.prototype.hook = function (name, fn) { var suite = this.suite; var hooks = suite['_' + name]; var self = this; - function next(i) { + function next (i) { var hook = hooks[i]; if (!hook) { return fn(); @@ -4718,12 +4791,12 @@ Runner.prototype.hook = function(name, fn) { self.emit('hook', hook); if (!hook.listeners('error').length) { - hook.on('error', function(err) { + hook.on('error', function (err) { self.failHook(hook, err); }); } - hook.run(function(err) { + hook.run(function (err) { var testError = hook.error(); if (testError) { self.fail(self.test, testError); @@ -4733,7 +4806,7 @@ Runner.prototype.hook = function(name, fn) { if (name === 'beforeEach' || name === 'afterEach') { self.test.pending = true; } else { - utils.forEach(suite.tests, function(test) { + utils.forEach(suite.tests, function (test) { test.pending = true; }); // a pending hook won't be executed twice. @@ -4752,7 +4825,7 @@ Runner.prototype.hook = function(name, fn) { }); } - Runner.immediately(function() { + Runner.immediately(function () { next(0); }); }; @@ -4766,11 +4839,11 @@ Runner.prototype.hook = function(name, fn) { * @param {Array} suites * @param {Function} fn */ -Runner.prototype.hooks = function(name, suites, fn) { +Runner.prototype.hooks = function (name, suites, fn) { var self = this; var orig = this.suite; - function next(suite) { + function next (suite) { self.suite = suite; if (!suite) { @@ -4778,7 +4851,7 @@ Runner.prototype.hooks = function(name, suites, fn) { return fn(); } - self.hook(name, function(err) { + self.hook(name, function (err) { if (err) { var errSuite = self.suite; self.suite = orig; @@ -4799,7 +4872,7 @@ Runner.prototype.hooks = function(name, suites, fn) { * @param {Function} fn * @api private */ -Runner.prototype.hookUp = function(name, fn) { +Runner.prototype.hookUp = function (name, fn) { var suites = [this.suite].concat(this.parents()).reverse(); this.hooks(name, suites, fn); }; @@ -4811,7 +4884,7 @@ Runner.prototype.hookUp = function(name, fn) { * @param {Function} fn * @api private */ -Runner.prototype.hookDown = function(name, fn) { +Runner.prototype.hookDown = function (name, fn) { var suites = [this.suite].concat(this.parents()); this.hooks(name, suites, fn); }; @@ -4823,7 +4896,7 @@ Runner.prototype.hookDown = function(name, fn) { * @return {Array} * @api private */ -Runner.prototype.parents = function() { +Runner.prototype.parents = function () { var suite = this.suite; var suites = []; while (suite.parent) { @@ -4839,7 +4912,7 @@ Runner.prototype.parents = function() { * @param {Function} fn * @api private */ -Runner.prototype.runTest = function(fn) { +Runner.prototype.runTest = function (fn) { var self = this; var test = this.test; @@ -4855,7 +4928,7 @@ Runner.prototype.runTest = function(fn) { return test.run(fn); } try { - test.on('error', function(err) { + test.on('error', function (err) { self.fail(test, err); }); test.run(fn); @@ -4871,12 +4944,12 @@ Runner.prototype.runTest = function(fn) { * @param {Suite} suite * @param {Function} fn */ -Runner.prototype.runTests = function(suite, fn) { +Runner.prototype.runTests = function (suite, fn) { var self = this; var tests = suite.tests.slice(); var test; - function hookErr(_, errSuite, after) { + function hookErr (_, errSuite, after) { // before/after Each hook for errSuite failed: var orig = self.suite; @@ -4886,7 +4959,7 @@ Runner.prototype.runTests = function(suite, fn) { if (self.suite) { // call hookUp afterEach - self.hookUp('afterEach', function(err2, errSuite2) { + self.hookUp('afterEach', function (err2, errSuite2) { self.suite = orig; // some hooks may fail even now if (err2) { @@ -4902,7 +4975,7 @@ Runner.prototype.runTests = function(suite, fn) { } } - function next(err, errSuite) { + function next (err, errSuite) { // if we bail after first err if (self.failures && suite._bail) { return fn(); @@ -4954,7 +5027,7 @@ Runner.prototype.runTests = function(suite, fn) { // execute test and hook(s) self.emit('test', self.test = test); - self.hookDown('beforeEach', function(err, errSuite) { + self.hookDown('beforeEach', function (err, errSuite) { if (test.isPending()) { self.emit('pending', test); self.emit('test end', test); @@ -4964,7 +5037,7 @@ Runner.prototype.runTests = function(suite, fn) { return hookErr(err, errSuite, false); } self.currentRunnable = self.test; - self.runTest(function(err) { + self.runTest(function (err) { test = self.test; if (err) { var retry = test.currentRetry(); @@ -5011,7 +5084,7 @@ Runner.prototype.runTests = function(suite, fn) { * @param {Suite} suite * @param {Function} fn */ -Runner.prototype.runSuite = function(suite, fn) { +Runner.prototype.runSuite = function (suite, fn) { var i = 0; var self = this; var total = this.grepTotal(suite); @@ -5025,7 +5098,7 @@ Runner.prototype.runSuite = function(suite, fn) { this.emit('suite', this.suite = suite); - function next(errSuite) { + function next (errSuite) { if (errSuite) { // current suite failed on a hook from errSuite if (errSuite === suite) { @@ -5051,7 +5124,7 @@ Runner.prototype.runSuite = function(suite, fn) { // huge recursive loop and thus a maximum call stack error. // See comment in `this.runTests()` for more information. if (self._grep !== self._defaultGrep) { - Runner.immediately(function() { + Runner.immediately(function () { self.runSuite(curr, next); }); } else { @@ -5059,7 +5132,7 @@ Runner.prototype.runSuite = function(suite, fn) { } } - function done(errSuite) { + function done (errSuite) { self.suite = suite; self.nextSuite = next; @@ -5073,7 +5146,7 @@ Runner.prototype.runSuite = function(suite, fn) { // remove reference to test delete self.test; - self.hook('afterAll', function() { + self.hook('afterAll', function () { self.emit('suite end', suite); fn(errSuite); }); @@ -5082,7 +5155,7 @@ Runner.prototype.runSuite = function(suite, fn) { this.nextSuite = next; - this.hook('beforeAll', function(err) { + this.hook('beforeAll', function (err) { if (err) { return done(); } @@ -5096,9 +5169,9 @@ Runner.prototype.runSuite = function(suite, fn) { * @param {Error} err * @api private */ -Runner.prototype.uncaught = function(err) { +Runner.prototype.uncaught = function (err) { if (err) { - debug('uncaught exception %s', err !== function() { + debug('uncaught exception %s', err !== function () { return this; }.call(err) ? err : (err.message || err)); } else { @@ -5169,8 +5242,8 @@ Runner.prototype.uncaught = function(err) { * * @param {Suite} suite */ -function cleanSuiteReferences(suite) { - function cleanArrReferences(arr) { +function cleanSuiteReferences (suite) { + function cleanArrReferences (arr) { for (var i = 0; i < arr.length; i++) { delete arr[i].fn; } @@ -5207,7 +5280,7 @@ function cleanSuiteReferences(suite) { * @param {Function} fn * @return {Runner} Runner instance. */ -Runner.prototype.run = function(fn) { +Runner.prototype.run = function (fn) { var self = this; var rootSuite = this.suite; @@ -5216,16 +5289,16 @@ Runner.prototype.run = function(fn) { filterOnly(rootSuite); } - fn = fn || function() {}; + fn = fn || function () {}; - function uncaught(err) { + function uncaught (err) { self.uncaught(err); } - function start() { + function start () { self.started = true; self.emit('start'); - self.runSuite(rootSuite, function() { + self.runSuite(rootSuite, function () { debug('finished running'); self.emit('end'); }); @@ -5237,7 +5310,7 @@ Runner.prototype.run = function(fn) { this.on('suite end', cleanSuiteReferences); // callback - this.on('end', function() { + this.on('end', function () { debug('end'); process.removeListener('uncaughtException', uncaught); fn(self.failures); @@ -5264,7 +5337,7 @@ Runner.prototype.run = function(fn) { * @api public * @return {Runner} Runner instance. */ -Runner.prototype.abort = function() { +Runner.prototype.abort = function () { debug('aborting'); this._abort = true; @@ -5278,7 +5351,7 @@ Runner.prototype.abort = function() { * @returns {Boolean} * @api private */ -function filterOnly(suite) { +function filterOnly (suite) { if (suite._onlyTests.length) { // If the suite contains `only` tests, run those and ignore any nested suites. suite.tests = suite._onlyTests; @@ -5286,7 +5359,7 @@ function filterOnly(suite) { } else { // Otherwise, do not run any of the tests in this suite. suite.tests = []; - utils.forEach(suite._onlySuites, function(onlySuite) { + utils.forEach(suite._onlySuites, function (onlySuite) { // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite. // Otherwise, all of the tests on this `only` suite should be run, so don't filter it. if (hasOnly(onlySuite)) { @@ -5294,7 +5367,7 @@ function filterOnly(suite) { } }); // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants. - suite.suites = filter(suite.suites, function(childSuite) { + suite.suites = filter(suite.suites, function (childSuite) { return indexOf(suite._onlySuites, childSuite) !== -1 || filterOnly(childSuite); }); } @@ -5309,7 +5382,7 @@ function filterOnly(suite) { * @returns {Boolean} * @api private */ -function hasOnly(suite) { +function hasOnly (suite) { return suite._onlyTests.length || suite._onlySuites.length || some(suite.suites, hasOnly); } @@ -5321,8 +5394,8 @@ function hasOnly(suite) { * @param {Array} globals * @return {Array} */ -function filterLeaks(ok, globals) { - return filter(globals, function(key) { +function filterLeaks (ok, globals) { + return filter(globals, function (key) { // Firefox and Chrome exposes iframes as index inside the window object if (/^\d+/.test(key)) { return false; @@ -5346,7 +5419,7 @@ function filterLeaks(ok, globals) { return false; } - var matched = filter(ok, function(ok) { + var matched = filter(ok, function (ok) { if (~ok.indexOf('*')) { return key.indexOf(ok.split('*')[0]) === 0; } @@ -5362,10 +5435,10 @@ function filterLeaks(ok, globals) { * @return {Array} * @api private */ -function extraGlobals() { +function extraGlobals () { if (typeof process === 'object' && typeof process.version === 'string') { var parts = process.version.split('.'); - var nodeVersion = utils.reduce(parts, function(a, v) { + var nodeVersion = utils.reduce(parts, function (a, v) { return a << 8 | v; }); @@ -5381,6 +5454,8 @@ function extraGlobals() { }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./pending":16,"./runnable":33,"./utils":38,"_process":67,"debug":2,"events":3}],35:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -5408,7 +5483,7 @@ exports = module.exports = Suite; * @param {string} title * @return {Suite} */ -exports.create = function(parent, title) { +exports.create = function (parent, title) { var suite = new Suite(title, parent.ctx); suite.parent = parent; title = suite.fullTitle(); @@ -5423,12 +5498,12 @@ exports.create = function(parent, title) { * @param {string} title * @param {Context} parentContext */ -function Suite(title, parentContext) { +function Suite (title, parentContext) { if (!utils.isString(title)) { throw new Error('Suite `title` should be a "string" but "' + typeof title + '" was given instead.'); } this.title = title; - function Context() {} + function Context () {} Context.prototype = parentContext; this.ctx = new Context(); this.suites = []; @@ -5460,7 +5535,7 @@ inherits(Suite, EventEmitter); * @api private * @return {Suite} */ -Suite.prototype.clone = function() { +Suite.prototype.clone = function () { var suite = new Suite(this.title); debug('clone'); suite.ctx = this.ctx; @@ -5479,7 +5554,7 @@ Suite.prototype.clone = function() { * @param {number|string} ms * @return {Suite|number} for chaining */ -Suite.prototype.timeout = function(ms) { +Suite.prototype.timeout = function (ms) { if (!arguments.length) { return this._timeout; } @@ -5501,7 +5576,7 @@ Suite.prototype.timeout = function(ms) { * @param {number|string} n * @return {Suite|number} for chaining */ -Suite.prototype.retries = function(n) { +Suite.prototype.retries = function (n) { if (!arguments.length) { return this._retries; } @@ -5517,7 +5592,7 @@ Suite.prototype.retries = function(n) { * @param {boolean} enabled * @return {Suite|boolean} self or enabled */ -Suite.prototype.enableTimeouts = function(enabled) { +Suite.prototype.enableTimeouts = function (enabled) { if (!arguments.length) { return this._enableTimeouts; } @@ -5533,7 +5608,7 @@ Suite.prototype.enableTimeouts = function(enabled) { * @param {number|string} ms * @return {Suite|number} for chaining */ -Suite.prototype.slow = function(ms) { +Suite.prototype.slow = function (ms) { if (!arguments.length) { return this._slow; } @@ -5552,7 +5627,7 @@ Suite.prototype.slow = function(ms) { * @param {boolean} bail * @return {Suite|number} for chaining */ -Suite.prototype.bail = function(bail) { +Suite.prototype.bail = function (bail) { if (!arguments.length) { return this._bail; } @@ -5566,7 +5641,7 @@ Suite.prototype.bail = function(bail) { * * @api private */ -Suite.prototype.isPending = function() { +Suite.prototype.isPending = function () { return this.pending || (this.parent && this.parent.isPending()); }; @@ -5578,7 +5653,7 @@ Suite.prototype.isPending = function() { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.beforeAll = function(title, fn) { +Suite.prototype.beforeAll = function (title, fn) { if (this.isPending()) { return this; } @@ -5608,7 +5683,7 @@ Suite.prototype.beforeAll = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.afterAll = function(title, fn) { +Suite.prototype.afterAll = function (title, fn) { if (this.isPending()) { return this; } @@ -5638,7 +5713,7 @@ Suite.prototype.afterAll = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.beforeEach = function(title, fn) { +Suite.prototype.beforeEach = function (title, fn) { if (this.isPending()) { return this; } @@ -5668,7 +5743,7 @@ Suite.prototype.beforeEach = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.afterEach = function(title, fn) { +Suite.prototype.afterEach = function (title, fn) { if (this.isPending()) { return this; } @@ -5697,7 +5772,7 @@ Suite.prototype.afterEach = function(title, fn) { * @param {Suite} suite * @return {Suite} for chaining */ -Suite.prototype.addSuite = function(suite) { +Suite.prototype.addSuite = function (suite) { suite.parent = this; suite.timeout(this.timeout()); suite.retries(this.retries()); @@ -5716,7 +5791,7 @@ Suite.prototype.addSuite = function(suite) { * @param {Test} test * @return {Suite} for chaining */ -Suite.prototype.addTest = function(test) { +Suite.prototype.addTest = function (test) { test.parent = this; test.timeout(this.timeout()); test.retries(this.retries()); @@ -5735,7 +5810,7 @@ Suite.prototype.addTest = function(test) { * @api public * @return {string} */ -Suite.prototype.fullTitle = function() { +Suite.prototype.fullTitle = function () { if (this.parent) { var full = this.parent.fullTitle(); if (full) { @@ -5751,8 +5826,8 @@ Suite.prototype.fullTitle = function() { * @api public * @return {number} */ -Suite.prototype.total = function() { - return utils.reduce(this.suites, function(sum, suite) { +Suite.prototype.total = function () { + return utils.reduce(this.suites, function (sum, suite) { return sum + suite.total(); }, 0) + this.tests.length; }; @@ -5765,9 +5840,9 @@ Suite.prototype.total = function() { * @param {Function} fn * @return {Suite} */ -Suite.prototype.eachTest = function(fn) { +Suite.prototype.eachTest = function (fn) { utils.forEach(this.tests, fn); - utils.forEach(this.suites, function(suite) { + utils.forEach(this.suites, function (suite) { suite.eachTest(fn); }); return this; @@ -5776,13 +5851,15 @@ Suite.prototype.eachTest = function(fn) { /** * This will run the root suite if we happen to be running in delayed mode. */ -Suite.prototype.run = function run() { +Suite.prototype.run = function run () { if (this.root) { this.emit('run'); } }; },{"./hook":7,"./ms":15,"./utils":38,"debug":2,"events":3}],36:[function(require,module,exports){ +'use strict'; + /** * Module dependencies. */ @@ -5804,7 +5881,7 @@ module.exports = Test; * @param {String} title * @param {Function} fn */ -function Test(title, fn) { +function Test (title, fn) { if (!isString(title)) { throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.'); } @@ -5820,7 +5897,7 @@ Test.prototype = create(Runnable.prototype, { constructor: Test }); -Test.prototype.clone = function() { +Test.prototype.clone = function () { var test = new Test(this.title, this.fn); test.timeout(this.timeout()); test.slow(this.slow()); @@ -5875,6 +5952,8 @@ module.exports = toISOString; },{}],38:[function(require,module,exports){ (function (process,Buffer){ +'use strict'; + /* eslint-env browser */ /** @@ -5908,7 +5987,7 @@ exports.inherits = require('util').inherits; * @param {string} html * @return {string} */ -exports.escape = function(html) { +exports.escape = function (html) { return String(html) .replace(/&/g, '&') .replace(/"/g, '"') @@ -5924,7 +6003,7 @@ exports.escape = function(html) { * @param {Function} fn * @param {Object} scope */ -exports.forEach = function(arr, fn, scope) { +exports.forEach = function (arr, fn, scope) { for (var i = 0, l = arr.length; i < l; i++) { fn.call(scope, arr[i], i); } @@ -5937,7 +6016,7 @@ exports.forEach = function(arr, fn, scope) { * @param {Object} obj * @return {boolean} */ -exports.isString = function(obj) { +exports.isString = function (obj) { return typeof obj === 'string'; }; @@ -5950,7 +6029,7 @@ exports.isString = function(obj) { * @param {Object} scope * @return {Array} */ -exports.map = function(arr, fn, scope) { +exports.map = function (arr, fn, scope) { var result = []; for (var i = 0, l = arr.length; i < l; i++) { result.push(fn.call(scope, arr[i], i, arr)); @@ -5967,7 +6046,7 @@ exports.map = function(arr, fn, scope) { * @param {number} start * @return {number} */ -var indexOf = exports.indexOf = function(arr, obj, start) { +var indexOf = exports.indexOf = function (arr, obj, start) { for (var i = start || 0, l = arr.length; i < l; i++) { if (arr[i] === obj) { return i; @@ -5985,7 +6064,7 @@ var indexOf = exports.indexOf = function(arr, obj, start) { * @param {Object} val Initial value. * @return {*} */ -var reduce = exports.reduce = function(arr, fn, val) { +var reduce = exports.reduce = function (arr, fn, val) { var rval = val; for (var i = 0, l = arr.length; i < l; i++) { @@ -6003,7 +6082,7 @@ var reduce = exports.reduce = function(arr, fn, val) { * @param {Function} fn * @return {Array} */ -exports.filter = function(arr, fn) { +exports.filter = function (arr, fn) { var ret = []; for (var i = 0, l = arr.length; i < l; i++) { @@ -6024,7 +6103,7 @@ exports.filter = function(arr, fn) { * @param {Function} fn * @return {Array} */ -exports.some = function(arr, fn) { +exports.some = function (arr, fn) { for (var i = 0, l = arr.length; i < l; i++) { if (fn(arr[i])) { return true; @@ -6040,7 +6119,7 @@ exports.some = function(arr, fn) { * @param {Object} obj * @return {Array} keys */ -exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) { +exports.keys = typeof Object.keys === 'function' ? Object.keys : function (obj) { var keys = []; var has = Object.prototype.hasOwnProperty; // for `window` on <=IE8 @@ -6061,11 +6140,11 @@ exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) { * @param {Array} files * @param {Function} fn */ -exports.watch = function(files, fn) { +exports.watch = function (files, fn) { var options = { interval: 100 }; - files.forEach(function(file) { + files.forEach(function (file) { debug('file %s', file); - watchFile(file, options, function(curr, prev) { + watchFile(file, options, function (curr, prev) { if (prev.mtime < curr.mtime) { fn(file); } @@ -6080,7 +6159,7 @@ exports.watch = function(files, fn) { * @param {Object} obj * @return {Boolean} */ -var isArray = typeof Array.isArray === 'function' ? Array.isArray : function(obj) { +var isArray = typeof Array.isArray === 'function' ? Array.isArray : function (obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; @@ -6092,7 +6171,7 @@ exports.isArray = isArray; * @type {Function} */ if (typeof Buffer !== 'undefined' && Buffer.prototype) { - Buffer.prototype.toJSON = Buffer.prototype.toJSON || function() { + Buffer.prototype.toJSON = Buffer.prototype.toJSON || function () { return Array.prototype.slice.call(this, 0); }; } @@ -6104,7 +6183,7 @@ if (typeof Buffer !== 'undefined' && Buffer.prototype) { * @param {string} path * @return {boolean} */ -function ignored(path) { +function ignored (path) { return !~ignore.indexOf(path); } @@ -6117,7 +6196,7 @@ function ignored(path) { * @param {Array} [ret=[]] * @return {Array} */ -exports.files = function(dir, ext, ret) { +exports.files = function (dir, ext, ret) { ret = ret || []; ext = ext || ['js']; @@ -6125,7 +6204,7 @@ exports.files = function(dir, ext, ret) { readdirSync(dir) .filter(ignored) - .forEach(function(path) { + .forEach(function (path) { path = join(dir, path); if (statSync(path).isDirectory()) { exports.files(path, ext, ret); @@ -6144,7 +6223,7 @@ exports.files = function(dir, ext, ret) { * @param {string} str * @return {string} */ -exports.slug = function(str) { +exports.slug = function (str) { return str .toLowerCase() .replace(/ +/g, '-') @@ -6157,7 +6236,7 @@ exports.slug = function(str) { * @param {string} str * @return {string} */ -exports.clean = function(str) { +exports.clean = function (str) { str = str .replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '') // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content @@ -6165,7 +6244,7 @@ exports.clean = function(str) { var spaces = str.match(/^\n?( *)/)[1].length; var tabs = str.match(/^\n?(\t*)/)[1].length; - var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm'); + var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm'); str = str.replace(re, ''); @@ -6179,7 +6258,7 @@ exports.clean = function(str) { * @param {string} str * @return {string} */ -exports.trim = function(str) { +exports.trim = function (str) { return str.replace(/^\s+|\s+$/g, ''); }; @@ -6190,8 +6269,8 @@ exports.trim = function(str) { * @param {string} qs * @return {Object} */ -exports.parseQuery = function(qs) { - return reduce(qs.replace('?', '').split('&'), function(obj, pair) { +exports.parseQuery = function (qs) { + return reduce(qs.replace('?', '').split('&'), function (obj, pair) { var i = pair.indexOf('='); var key = pair.slice(0, i); var val = pair.slice(++i); @@ -6208,7 +6287,7 @@ exports.parseQuery = function(qs) { * @param {string} js * @return {string} */ -function highlight(js) { +function highlight (js) { return js .replace(/</g, '<') .replace(/>/g, '>') @@ -6226,7 +6305,7 @@ function highlight(js) { * @api private * @param {string} name */ -exports.highlightTags = function(name) { +exports.highlightTags = function (name) { var code = document.getElementById('mocha').getElementsByTagName(name); for (var i = 0, len = code.length; i < len; ++i) { code[i].innerHTML = highlight(code[i].innerHTML); @@ -6247,7 +6326,7 @@ exports.highlightTags = function(name) { * @param {string} typeHint The type of the value * @returns {string} */ -function emptyRepresentation(value, typeHint) { +function emptyRepresentation (value, typeHint) { switch (typeHint) { case 'function': return '[Function]'; @@ -6281,7 +6360,7 @@ function emptyRepresentation(value, typeHint) { * type(global) // 'global' * type(new String('foo') // 'object' */ -var type = exports.type = function type(value) { +var type = exports.type = function type (value) { if (value === undefined) { return 'undefined'; } else if (value === null) { @@ -6309,7 +6388,7 @@ var type = exports.type = function type(value) { * @param {*} value * @return {string} */ -exports.stringify = function(value) { +exports.stringify = function (value) { var typeHint = type(value); if (!~indexOf(['object', 'array', 'function'], typeHint)) { @@ -6323,7 +6402,7 @@ exports.stringify = function(value) { // IE7/IE8 has a bizarre String constructor; needs to be coerced // into an array and back to obj. if (typeHint === 'string' && typeof value === 'object') { - value = reduce(value.split(''), function(acc, char, idx) { + value = reduce(value.split(''), function (acc, char, idx) { acc[idx] = char; return acc; }, {}); @@ -6351,7 +6430,7 @@ exports.stringify = function(value) { * @param {number=} depth * @returns {*} */ -function jsonStringify(object, spaces, depth) { +function jsonStringify (object, spaces, depth) { if (typeof spaces === 'undefined') { // primitive types return _stringify(object); @@ -6363,11 +6442,11 @@ function jsonStringify(object, spaces, depth) { var end = isArray(object) ? ']' : '}'; var length = typeof object.length === 'number' ? object.length : exports.keys(object).length; // `.repeat()` polyfill - function repeat(s, n) { + function repeat (s, n) { return new Array(n).join(s); } - function _stringify(val) { + function _stringify (val) { switch (type(val)) { case 'null': case 'undefined': @@ -6413,15 +6492,15 @@ function jsonStringify(object, spaces, depth) { continue; // not my business } --length; - str += '\n ' + repeat(' ', space) - + (isArray(object) ? '' : '"' + i + '": ') // key - + _stringify(object[i]) // value - + (length ? ',' : ''); // comma + str += '\n ' + repeat(' ', space) + + (isArray(object) ? '' : '"' + i + '": ') + // key + _stringify(object[i]) + // value + (length ? ',' : ''); // comma } - return str + return str + // [], {} - + (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end); + (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end); } /** @@ -6431,7 +6510,7 @@ function jsonStringify(object, spaces, depth) { * @param {*} value The value to test. * @return {boolean} True if `value` is a buffer, otherwise false */ -exports.isBuffer = function(value) { +exports.isBuffer = function (value) { return typeof Buffer !== 'undefined' && Buffer.isBuffer(value); }; @@ -6454,13 +6533,13 @@ exports.isBuffer = function(value) { * @param {string} [typeHint] Type hint * @return {(Object|Array|Function|string|undefined)} */ -exports.canonicalize = function canonicalize(value, stack, typeHint) { +exports.canonicalize = function canonicalize (value, stack, typeHint) { var canonicalizedObj; /* eslint-disable no-unused-vars */ var prop; /* eslint-enable no-unused-vars */ typeHint = typeHint || type(value); - function withStack(value, fn) { + function withStack (value, fn) { stack.push(value); fn(); stack.pop(); @@ -6479,8 +6558,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { canonicalizedObj = value; break; case 'array': - withStack(value, function() { - canonicalizedObj = exports.map(value, function(item) { + withStack(value, function () { + canonicalizedObj = exports.map(value, function (item) { return exports.canonicalize(item, stack); }); }); @@ -6499,8 +6578,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { /* falls through */ case 'object': canonicalizedObj = canonicalizedObj || {}; - withStack(value, function() { - exports.forEach(exports.keys(value).sort(), function(key) { + withStack(value, function () { + exports.forEach(exports.keys(value).sort(), function (key) { canonicalizedObj[key] = exports.canonicalize(value[key], stack); }); }); @@ -6528,7 +6607,7 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { * @param {boolean} recursive Whether or not to recurse into subdirectories. * @return {string[]} An array of paths. */ -exports.lookupFiles = function lookupFiles(path, extensions, recursive) { +exports.lookupFiles = function lookupFiles (path, extensions, recursive) { var files = []; var re = new RegExp('\\.(' + extensions.join('|') + ')$'); @@ -6554,7 +6633,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) { return; } - readdirSync(path).forEach(function(file) { + readdirSync(path).forEach(function (file) { file = join(path, file); try { var stat = statSync(file); @@ -6583,7 +6662,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) { * @return {Error} */ -exports.undefinedError = function() { +exports.undefinedError = function () { return new Error('Caught undefined error, did you throw without specifying what?'); }; @@ -6594,7 +6673,7 @@ exports.undefinedError = function() { * @return {Error} */ -exports.getError = function(err) { +exports.getError = function (err) { return err || exports.undefinedError(); }; @@ -6607,7 +6686,7 @@ exports.getError = function(err) { * (i.e: strip Mocha and internal node functions from stack trace). * @returns {Function} */ -exports.stackTraceFilter = function() { +exports.stackTraceFilter = function () { // TODO: Replace with `process.browser` var is = typeof document === 'undefined' ? { node: true } : { browser: true }; var slash = path.sep; @@ -6619,26 +6698,26 @@ exports.stackTraceFilter = function() { slash = '/'; } - function isMochaInternal(line) { - return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) - || (~line.indexOf('node_modules' + slash + 'mocha.js')) - || (~line.indexOf('bower_components' + slash + 'mocha.js')) - || (~line.indexOf(slash + 'mocha.js')); + function isMochaInternal (line) { + return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) || + (~line.indexOf('node_modules' + slash + 'mocha.js')) || + (~line.indexOf('bower_components' + slash + 'mocha.js')) || + (~line.indexOf(slash + 'mocha.js')); } - function isNodeInternal(line) { - return (~line.indexOf('(timers.js:')) - || (~line.indexOf('(events.js:')) - || (~line.indexOf('(node.js:')) - || (~line.indexOf('(module.js:')) - || (~line.indexOf('GeneratorFunctionPrototype.next (native)')) - || false; + function isNodeInternal (line) { + return (~line.indexOf('(timers.js:')) || + (~line.indexOf('(events.js:')) || + (~line.indexOf('(node.js:')) || + (~line.indexOf('(module.js:')) || + (~line.indexOf('GeneratorFunctionPrototype.next (native)')) || + false; } - return function(stack) { + return function (stack) { stack = stack.split('\n'); - stack = reduce(stack, function(list, line) { + stack = reduce(stack, function (list, line) { if (isMochaInternal(line)) { return list; } @@ -6666,14 +6745,21 @@ exports.stackTraceFilter = function() { * @param {*} value * @returns {boolean} Whether or not `value` is a Promise */ -exports.isPromise = function isPromise(value) { +exports.isPromise = function isPromise (value) { return typeof value === 'object' && typeof value.then === 'function'; }; +/** + * It's a noop. + * @api + */ +exports.noop = function () {}; + }).call(this,require('_process'),require("buffer").Buffer) },{"./to-iso-string":37,"_process":67,"buffer":44,"debug":2,"fs":42,"glob":42,"json3":54,"path":42,"util":84}],39:[function(require,module,exports){ 'use strict' +exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray @@ -6681,23 +6767,17 @@ var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array -function init () { - var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i - } - - revLookup['-'.charCodeAt(0)] = 62 - revLookup['_'.charCodeAt(0)] = 63 +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i } -init() +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 -function toByteArray (b64) { - var i, j, l, tmp, placeHolders, arr +function placeHoldersCount (b64) { var len = b64.length - if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } @@ -6707,9 +6787,19 @@ function toByteArray (b64) { // represent one byte // if there is only one, then the three characters before it represent 2 bytes // this is just a cheap hack to not do indexOf twice - placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} +function byteLength (b64) { // base64 is 4/3 + up to two characters of the original data + return b64.length * 3 / 4 - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + arr = new Arr(len * 3 / 4 - placeHolders) // if there are placeholders, only get up to the last complete 4 chars diff --git a/tests/lib/mocha-3.1.0/package.json b/tests/lib/mocha-3.1.2/package.json index 4ec6546e6d..475f92513f 100644 --- a/tests/lib/mocha-3.1.0/package.json +++ b/tests/lib/mocha-3.1.2/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "3.1.0", + "version": "3.1.2", "description": "simple, flexible, fun test framework", "keywords": [ "mocha", @@ -314,17 +314,24 @@ "supports-color": "3.1.2" }, "devDependencies": { + "assert": "^1.4.1", "browserify": "^13.0.0", "coffee-script": "^1.10.0", "eslint": "^2.13.1", + "eslint-config-semistandard": "^6.0.2", + "eslint-config-standard": "^5.0.0", + "eslint-plugin-promise": "^2.0.1", + "eslint-plugin-standard": "1.3.2", "expect.js": "^0.3.1", "karma": "^1.1.0", "karma-browserify": "^5.0.5", + "karma-chrome-launcher": "^2.0.0", "karma-expect": "^1.1.2", "karma-no-mocha": "^2.0.0", "karma-phantomjs-launcher": "^0.2.3", "karma-sauce-launcher": "^1.0.0", "karma-spec-reporter": "0.0.26", + "os-name": "^2.0.1", "phantomjs": "1.9.8", "rimraf": "^2.5.2", "should": "^9.0.2", diff --git a/tests/lib/mocha-3.1.0/scripts/dedefine.js b/tests/lib/mocha-3.1.2/scripts/dedefine.js index c647c0e083..3e297586c9 100644 --- a/tests/lib/mocha-3.1.0/scripts/dedefine.js +++ b/tests/lib/mocha-3.1.2/scripts/dedefine.js @@ -8,16 +8,16 @@ var through = require('through2'); var defineRx = /typeof define === ['"]function['"] && define\.amd/g; -function createStream() { - return through.obj(function(chunk, enc, next) { +function createStream () { + return through.obj(function (chunk, enc, next) { this.push(String(chunk) .replace(defineRx, 'false')); next(); }); } -module.exports = function(b) { - function wrap() { +module.exports = function (b) { + function wrap () { b.pipeline.get('wrap').push(createStream()); } diff --git a/tests/lib/mocha-3.1.0/scripts/travis-after-script.sh b/tests/lib/mocha-3.1.2/scripts/travis-after-script.sh index e93c98f796..e93c98f796 100644 --- a/tests/lib/mocha-3.1.0/scripts/travis-after-script.sh +++ b/tests/lib/mocha-3.1.2/scripts/travis-after-script.sh diff --git a/tests/lib/mocha-3.1.0/scripts/travis-before-install.sh b/tests/lib/mocha-3.1.2/scripts/travis-before-install.sh index 9913070ae9..9913070ae9 100644 --- a/tests/lib/mocha-3.1.0/scripts/travis-before-install.sh +++ b/tests/lib/mocha-3.1.2/scripts/travis-before-install.sh diff --git a/tests/lib/mocha-3.1.0/scripts/travis-before-script.sh b/tests/lib/mocha-3.1.2/scripts/travis-before-script.sh index e5c6b25414..e5c6b25414 100644 --- a/tests/lib/mocha-3.1.0/scripts/travis-before-script.sh +++ b/tests/lib/mocha-3.1.2/scripts/travis-before-script.sh diff --git a/tests/lib/mocha-3.1.2/test/.eslintrc.yaml b/tests/lib/mocha-3.1.2/test/.eslintrc.yaml new file mode 100644 index 0000000000..1830a0b6f4 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/.eslintrc.yaml @@ -0,0 +1,7 @@ +env: + mocha: true +globals: + expect: false + assert: false + # https://github.com/sindresorhus/globals/pull/102 + run: false diff --git a/tests/lib/mocha-3.1.0/test/acceptance/context.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/context.spec.js index 69dea139c9..cbcdedb49d 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/context.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/context.spec.js @@ -1,72 +1,73 @@ -describe('Context', function(){ - beforeEach(function(){ +'use strict'; + +describe('Context', function () { + beforeEach(function () { this.calls = ['before']; - }) + }); - describe('nested', function(){ - beforeEach(function(){ + describe('nested', function () { + beforeEach(function () { this.calls.push('before two'); - }) + }); - it('should work', function(){ + it('should work', function () { expect(this.calls).to.eql(['before', 'before two']); this.calls.push('test'); - }) + }); - after(function(){ + after(function () { expect(this.calls).to.eql(['before', 'before two', 'test']); this.calls.push('after two'); - }) - }) + }); + }); - after(function(){ + after(function () { expect(this.calls).to.eql(['before', 'before two', 'test', 'after two']); - }) -}) + }); +}); -describe('Context Siblings', function(){ - beforeEach(function(){ +describe('Context Siblings', function () { + beforeEach(function () { this.calls = ['before']; - }) + }); - describe('sequestered sibling', function(){ - beforeEach(function(){ + describe('sequestered sibling', function () { + beforeEach(function () { this.calls.push('before two'); this.hiddenFromSibling = 'This should be hidden'; - }) + }); - it('should work', function(){ - expect(this.hiddenFromSibling).to.eql('This should be hidden') - }) - }) + it('should work', function () { + expect(this.hiddenFromSibling).to.eql('This should be hidden'); + }); + }); - describe('sibling verifiction', function(){ - beforeEach(function(){ + describe('sibling verifiction', function () { + beforeEach(function () { this.calls.push('before sibling'); - }) + }); - it('should not have value set within a sibling describe', function(){ + it('should not have value set within a sibling describe', function () { expect('This should be hidden').not.to.eql(this.hiddenFromSibling); this.visibleFromTestSibling = 'Visible from test sibling'; - }) + }); - it('should allow test siblings to modify shared context', function(){ + it('should allow test siblings to modify shared context', function () { expect('Visible from test sibling').to.eql(this.visibleFromTestSibling); - }) + }); - it('should have reset this.calls before describe', function(){ + it('should have reset this.calls before describe', function () { expect(this.calls).to.eql(['before', 'before sibling']); - }) - }) + }); + }); - after(function(){ + after(function () { expect(this.calls).to.eql(['before', 'before sibling']); - }) - -}) + }); +}); -describe('timeout()', function(){ - it('should return the timeout', function(){ +describe('timeout()', function () { + it('should return the timeout', function () { expect(this.timeout()).to.equal(200); }); }); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/duration.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/duration.spec.js new file mode 100644 index 0000000000..0194d4408c --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/duration.spec.js @@ -0,0 +1,27 @@ +'use strict'; + +describe('durations', function () { + describe('when slow', function () { + it('should highlight in red', function (done) { + setTimeout(function () { + done(); + }, 100); + }); + }); + + describe('when reasonable', function () { + it('should highlight in yellow', function (done) { + setTimeout(function () { + done(); + }, 50); + }); + }); + + describe('when fast', function () { + it('should highlight in green', function (done) { + setTimeout(function () { + done(); + }, 10); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/fs.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/fs.spec.js new file mode 100644 index 0000000000..9d0357c382 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/fs.spec.js @@ -0,0 +1,22 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var os = require('os'); +var tmpFile = path.join.bind(path, os.tmpdir()); + +describe('fs.readFile()', function () { + describe('when the file exists', function () { + it('should succeed', function (done) { + fs.writeFile(tmpFile('mocha'), 'wahoo', done); + }); + }); + + describe('when the file does not exist', function () { + it('should fail', function (done) { + // uncomment + // fs.readFile(tmpFile('does-not-exist'), done); + done(); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/glob/glob.sh b/tests/lib/mocha-3.1.2/test/acceptance/glob/glob.sh index 823ba07fb9..823ba07fb9 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/glob/glob.sh +++ b/tests/lib/mocha-3.1.2/test/acceptance/glob/glob.sh diff --git a/tests/lib/mocha-3.1.2/test/acceptance/glob/glob.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/glob/glob.spec.js new file mode 100644 index 0000000000..eca3733898 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/glob/glob.spec.js @@ -0,0 +1,7 @@ +'use strict'; + +describe('globbing test', function () { + it('should find this test', function () { + // see glob.sh for details + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/globals.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/globals.spec.js index f8ef804b23..b87df9fd99 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/globals.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/globals.spec.js @@ -1,40 +1,42 @@ -describe('global leaks', function(){ - before(function(){ +'use strict'; + +describe('global leaks', function () { + before(function () { // uncomment to test // foo = 'hey'; // bar = 'hey'; - }) + }); - beforeEach(function(){ + beforeEach(function () { // uncomment to test // foo = 'bar' }); - it('should cause tests to fail', function(){ + it('should cause tests to fail', function () { // uncomment to test // foo = 'bar'; // bar = 'baz'; // baz = 'raz'; }); - it('should pass when accepted', function(){ + it('should pass when accepted', function () { global.okGlobalA = 1; global.okGlobalB = 1; global.okGlobalC = 1; - }) + }); - it('should pass with wildcard', function(){ + it('should pass with wildcard', function () { global.callback123 = 'foo'; global.callback345 = 'bar'; }); - it('should pass when prefixed "mocha-"', function(){ + it('should pass when prefixed "mocha-"', function () { // Opera and IE do this for HTML element IDs anyway // but to sure we can assert this in any browser, simulate it. global['mocha-example'] = { nodeType: 1 }; }); - afterEach(function(){ + afterEach(function () { // uncomment to test // foo = 'bar' }); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/http.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/http.spec.js new file mode 100644 index 0000000000..b8bc2f7e26 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/http.spec.js @@ -0,0 +1,18 @@ +'use strict'; + +var http = require('http'); + +var server = http.createServer(function (req, res) { + res.end('Hello World\n'); +}); + +server.listen(8888); + +describe('http', function () { + it('should provide an example', function (done) { + http.get({ path: '/', port: 8888 }, function (res) { + expect(res).to.have.property('statusCode', 200); + done(); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/interfaces/bdd.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/bdd.spec.js new file mode 100644 index 0000000000..f6e24d88a8 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/bdd.spec.js @@ -0,0 +1,34 @@ +'use strict'; + +describe('integer primitives', function () { + describe('arithmetic', function () { + it('should add', function () { + expect(1 + 1).to.equal(2); + expect(2 + 2).to.equal(4); + }); + + it('should subtract', function () { + expect(1 - 1).to.equal(0); + expect(2 - 1).to.equal(1); + }); + }); +}); + +describe('integer primitives', function () { + describe('arithmetic is not', function () { + it('should add', function () { + expect(1 + 1).not.to.equal(3); + expect(2 + 2).not.to.equal(5); + }); + }); +}); + +context('test suite', function () { + beforeEach(function () { + this.number = 5; + }); + + specify('share a property', function () { + expect(this.number).to.equal(5); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/interfaces/exports.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/exports.spec.js new file mode 100644 index 0000000000..f53c6a4ca0 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/exports.spec.js @@ -0,0 +1,48 @@ +'use strict'; + +var calls = []; + +exports.Array = { + before: function () { + calls.push('before'); + }, + + after: function () { + calls.push('after'); + expect(calls) + .to + .eql([ + 'before', + 'before each', + 'one', + 'after each', + 'before each', + 'two', + 'after each', + 'after' + ]); + }, + + '#indexOf()': { + beforeEach: function () { + calls.push('before each'); + }, + + afterEach: function () { + calls.push('after each'); + }, + + 'should return -1 when the value is not present': function () { + calls.push('one'); + expect([1, 2, 3].indexOf(5)).to.equal(-1); + expect([1, 2, 3].indexOf(0)).to.equal(-1); + }, + + 'should return the correct index when the value is present': function () { + calls.push('two'); + expect([1, 2, 3].indexOf(1)).to.equal(0); + expect([1, 2, 3].indexOf(2)).to.equal(1); + expect([1, 2, 3].indexOf(3)).to.equal(2); + } + } +}; diff --git a/tests/lib/mocha-3.1.2/test/acceptance/interfaces/qunit.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/qunit.spec.js new file mode 100644 index 0000000000..0d15272f0b --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/qunit.spec.js @@ -0,0 +1,25 @@ +'use strict'; + +function ok (expr, msg) { + if (!expr) throw new Error(msg); +} + +suite('integer primitives'); + +test('should add', function () { + var number = 2 + 2; + ok(number === 4); +}); + +test('should decrement', function () { + var number = 3; + ok(--number === 2); + ok(--number === 1); + ok(--number === 0); +}); + +suite('String'); + +test('#length', function () { + ok('foo'.length === 3); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/tdd.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/tdd.spec.js index 7ad079e36d..c2db518d70 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/interfaces/tdd.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/interfaces/tdd.spec.js @@ -1,38 +1,40 @@ -suite('integer primitives', function(){ - suite('arithmetic', function(){ +'use strict'; + +suite('integer primitives', function () { + suite('arithmetic', function () { var initialValue = 41; - suiteSetup(function(done){ + suiteSetup(function (done) { expect(initialValue).to.eql(41); initialValue += 1; done(); }); - test('should add', function(){ + test('should add', function () { expect(initialValue).to.eql(42); expect(1 + 1).to.equal(2); expect(2 + 2).to.equal(4); }); - test('should subtract', function(){ + test('should subtract', function () { expect(initialValue).to.eql(42); expect(1 - 1).to.equal(0); expect(2 - 1).to.equal(1); }); - test.skip('should skip this test', function(){ + test.skip('should skip this test', function () { var zero = 0; expect(zero).to.equal(1, 'this test should have been skipped'); }); - suite.skip('should skip this suite', function(){ - test('should skip this test', function(){ + suite.skip('should skip this suite', function () { + test('should skip this test', function () { var zero = 0; expect(zero).to.equal(1, 'this test should have been skipped'); }); }); - suiteTeardown(function(done){ + suiteTeardown(function (done) { expect(initialValue).to.eql(42); done(); }); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/lookup-files.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/lookup-files.spec.js index 5d4a48d8af..faf31b1375 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/lookup-files.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/lookup-files.spec.js @@ -7,13 +7,13 @@ var os = require('os'); var mkdirp = require('mkdirp'); var rimraf = require('rimraf'); -describe('lookupFiles', function() { +describe('lookupFiles', function () { var tmpDir = path.join(os.tmpDir(), 'mocha-lookup-files'); var existsSync = fs.existsSync; var tmpFile = path.join.bind(path, tmpDir); var symlinkSupported = false; - (function testSymlinkSupport() { + (function testSymlinkSupport () { makeTempDir(); fs.writeFileSync(tmpFile('mocha-utils.js'), 'yippy skippy ying yang yow'); @@ -27,7 +27,7 @@ describe('lookupFiles', function() { } }()); - beforeEach(function() { + beforeEach(function () { makeTempDir(); fs.writeFileSync(tmpFile('mocha-utils.js'), 'yippy skippy ying yang yow'); @@ -36,7 +36,7 @@ describe('lookupFiles', function() { } }); - (symlinkSupported ? it : it.skip)('should not choke on symlinks', function() { + (symlinkSupported ? it : it.skip)('should not choke on symlinks', function () { expect(utils.lookupFiles(tmpDir, ['js'], false)) .to .contain(tmpFile('mocha-utils-link.js')) @@ -57,7 +57,7 @@ describe('lookupFiles', function() { .eql([]); }); - it('should accept a glob "path" value', function() { + it('should accept a glob "path" value', function () { var res = utils.lookupFiles(tmpFile('mocha-utils*'), ['js'], false) .map(path.normalize.bind(path)); @@ -80,11 +80,11 @@ describe('lookupFiles', function() { afterEach(removeTempDir); - function makeTempDir() { + function makeTempDir () { mkdirp.sync(tmpDir); } - function removeTempDir() { + function removeTempDir () { rimraf.sync(tmpDir); } }); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/exit.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/exit.spec.js index 113e392300..916752f9b1 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/exit.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/exit.spec.js @@ -1,18 +1,20 @@ -describe('exit', function(){ - //note --bail works nicely in that it still allows an 'early exit' in an error scenario - it('should not exit even in error scenario if called with --no-exit', function(done){ +'use strict'; + +describe('exit', function () { + // note --bail works nicely in that it still allows an 'early exit' in an error scenario + it('should not exit even in error scenario if called with --no-exit', function (done) { done(new Error('failure')); - }) + }); - it('should take a long time to exit if called with --no-exit', function(done){ + it('should take a long time to exit if called with --no-exit', function (done) { done(); - setTimeout(function() { + setTimeout(function () { console.log('all done'); - }, 2500) - }) + }, 2500); + }); it('should kill all processes when SIGINT received', function () { // uncomment to test - //while (true) {} + // while (true) {} }); -}) +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/many.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/many.spec.js index 26538bc66e..d4e4a1e806 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/many.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/many.spec.js @@ -1,27 +1,28 @@ +'use strict'; + // Useful for testing SIGINT handler // use env.big_number to tune iterations so that you have time to ctrl+c -describe('a load of tests', function(){ - it('should fail the first test', function(){ +describe('a load of tests', function () { + it('should fail the first test', function () { throw new Error('this should appear in the summary'); - }) + }); var iterations = (process.env.big_number || 1e7); - function work() { + function work () { var a = 0; - for(var i=0; i<iterations; ++i) { + for (var i = 0; i < iterations; ++i) { a += i; } } - function addTest() { - it('should pass test ' + i, function(){ + function addTest () { + it('should pass test ' + i, function () { work(); - }) + }); } - for(var i=0; i<500; ++i) { + for (var i = 0; i < 500; ++i) { addTest(); } - -}) +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/misc/nontty.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/nontty.spec.js new file mode 100644 index 0000000000..ea57b9733f --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/nontty.spec.js @@ -0,0 +1,11 @@ +'use strict'; + +describe('tests for non-tty', function () { + it('should pass', function () { + + }); + + it('should fail', function () { + throw new Error('oh noes'); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/bdd-require.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/bdd-require.spec.js index 516dad7afa..14710c4cd2 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/bdd-require.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/bdd-require.spec.js @@ -1,4 +1,6 @@ -/*jshint node: true */ +'use strict'; + +/* jshint node: true */ var mocha = require('../../../../lib/mocha'); @@ -6,12 +8,12 @@ var beforeEach = mocha.beforeEach; var it = mocha.it; var describe = mocha.describe; -describe('it.only via require("mocha")', function() { - beforeEach(function() { +describe('it.only via require("mocha")', function () { + beforeEach(function () { this.didRunBeforeEach = true; }); - describe("nested within a describe/context", function() { - it.only('should run all enclosing beforeEach hooks', function() { + describe('nested within a describe/context', function () { + it.only('should run all enclosing beforeEach hooks', function () { require('assert').equal(this.didRunBeforeEach, true); }); }); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/bdd.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/bdd.spec.js index 7a33a74eac..639ab30e1b 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/bdd.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/bdd.spec.js @@ -1,75 +1,77 @@ -describe('should only run .only test in this bdd suite', function() { - it('should not run this test', function() { +'use strict'; + +describe('should only run .only test in this bdd suite', function () { + it('should not run this test', function () { (0).should.equal(1, 'this test should have been skipped'); }); - it.only('should run this test', function() { + it.only('should run this test', function () { (0).should.equal(0, 'this .only test should run'); }); - it('should run this test, not (includes the title of the .only test)', function() { + it('should run this test, not (includes the title of the .only test)', function () { (0).should.equal(1, 'this test should have been skipped'); }); }); -describe('should not run this suite', function() { - it('should not run this test', function() { +describe('should not run this suite', function () { + it('should not run this test', function () { (true).should.equal(false); }); - it('should not run this test', function() { + it('should not run this test', function () { (true).should.equal(false); }); - it('should not run this test', function() { + it('should not run this test', function () { (true).should.equal(false); }); }); -describe.only('should run all tests in this bdd suite', function() { - it('should run this test #1', function() { +describe.only('should run all tests in this bdd suite', function () { + it('should run this test #1', function () { (true).should.equal(true); }); - it('should run this test #2', function() { + it('should run this test #2', function () { (1).should.equal(1); }); - it('should run this test #3', function() { + it('should run this test #3', function () { ('foo').should.equal('foo'); }); }); -describe('should run only suites that marked as `only`', function() { - describe.only('should run all this tdd suite', function() { - it('should run this test #1', function() { +describe('should run only suites that marked as `only`', function () { + describe.only('should run all this tdd suite', function () { + it('should run this test #1', function () { (true).should.equal(true); }); - it('should run this test #2', function() { + it('should run this test #2', function () { (true).should.equal(true); }); }); - describe('should not run this suite', function() { - it('should run this test', function() { + describe('should not run this suite', function () { + it('should run this test', function () { (true).should.equal(false); }); }); }); // Nested situation -describe('should not run parent tests', function() { - it('should not run this test', function() { +describe('should not run parent tests', function () { + it('should not run this test', function () { (true).should.equal(false); }); - describe('and not the child tests too', function() { - it('should not run this test', function() { + describe('and not the child tests too', function () { + it('should not run this test', function () { (true).should.equal(false); }); - describe.only('but run all the tests in this suite', function() { - it('should run this test #1', function() { + describe.only('but run all the tests in this suite', function () { + it('should run this test #1', function () { (true).should.equal(true); }); - it('should run this test #2', function() { + it('should run this test #2', function () { (true).should.equal(true); }); }); @@ -77,49 +79,49 @@ describe('should not run parent tests', function() { }); // mark test as `only` override the suite behavior -describe.only('should run only tests that marked as `only`', function() { - it('should not run this test #1', function() { +describe.only('should run only tests that marked as `only`', function () { + it('should not run this test #1', function () { (false).should.equal(true); }); - it.only('should run this test #2', function() { + it.only('should run this test #2', function () { (true).should.equal(true); }); - it('should not run this test #3', function() { + it('should not run this test #3', function () { (false).should.equal(true); }); - it.only('should run this test #4', function() { + it.only('should run this test #4', function () { (true).should.equal(true); }); }); -describe.only('Should run only test cases that mark as only', function() { - it.only('should runt his test', function() { +describe.only('Should run only test cases that mark as only', function () { + it.only('should runt his test', function () { (true).should.equal(true); }); - it('should not run this test', function() { + it('should not run this test', function () { (false).should.equal(true); }); - describe('should not run this suite', function() { - it('should not run this test', function() { + describe('should not run this suite', function () { + it('should not run this test', function () { (false).should.equal(true); }); }); }); // Root Suite -it.only('#Root-Suite, should run this test-case #1', function() { +it.only('#Root-Suite, should run this test-case #1', function () { (true).should.equal(true); }); -it.only('#Root-Suite, should run this test-case #2', function() { +it.only('#Root-Suite, should run this test-case #2', function () { (true).should.equal(true); }); -it('#Root-Suite, should not run this test', function() { +it('#Root-Suite, should not run this test', function () { (false).should.equal(true); }); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/global/bdd.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/global/bdd.spec.js index e923876f84..1fc3d14384 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/global/bdd.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/global/bdd.spec.js @@ -1,12 +1,14 @@ +'use strict'; + // Root-only test cases -it.only('#Root-Suite, should run this bdd test-case #1', function() { +it.only('#Root-Suite, should run this bdd test-case #1', function () { (true).should.equal(true); }); -it('#Root-Suite, should not run this bdd test-case #2', function() { +it('#Root-Suite, should not run this bdd test-case #2', function () { (false).should.equal(true); }); -it('#Root-Suite, should not run this bdd test-case #3', function() { +it('#Root-Suite, should not run this bdd test-case #3', function () { (false).should.equal(true); -});
\ No newline at end of file +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/global/qunit.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/global/qunit.spec.js index 59ad72c3bf..69bbd3467a 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/global/qunit.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/global/qunit.spec.js @@ -1,12 +1,14 @@ +'use strict'; + // Root-only test cases -test.only('#Root-Suite, should run this qunit test-case #1', function() { +test.only('#Root-Suite, should run this qunit test-case #1', function () { (true).should.equal(true); }); -test('#Root-Suite, should not run this qunit test-case #2', function() { +test('#Root-Suite, should not run this qunit test-case #2', function () { (false).should.equal(true); }); -test('#Root-Suite, should not run this qunit test-case #3', function() { +test('#Root-Suite, should not run this qunit test-case #3', function () { (false).should.equal(true); -});
\ No newline at end of file +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/global/tdd.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/global/tdd.spec.js index 08d456848b..03fdea768f 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/global/tdd.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/global/tdd.spec.js @@ -1,12 +1,14 @@ +'use strict'; + // Root-only test cases -test.only('#Root-Suite, should run this tdd test-case #1', function() { +test.only('#Root-Suite, should run this tdd test-case #1', function () { (true).should.equal(true); }); -test('#Root-Suite, should not run this tdd test-case #2', function() { +test('#Root-Suite, should not run this tdd test-case #2', function () { (false).should.equal(true); }); -test('#Root-Suite, should not run this tdd test-case #3', function() { +test('#Root-Suite, should not run this tdd test-case #3', function () { (false).should.equal(true); -});
\ No newline at end of file +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/qunit.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/qunit.spec.js index 1248adeba7..77bdfcc64f 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/misc/only/qunit.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/qunit.spec.js @@ -1,73 +1,75 @@ +'use strict'; + // Root Suite -test.only('#Root-Suite, should run this test-case #1', function() { +test.only('#Root-Suite, should run this test-case #1', function () { (true).should.equal(true); }); -test.only('#Root-Suite, should run this test-case #2', function() { +test.only('#Root-Suite, should run this test-case #2', function () { (true).should.equal(true); }); -test('#Root-Suite, should not run this test', function() { +test('#Root-Suite, should not run this test', function () { (false).should.equal(true); }); suite('should only run .only test in this qunit suite'); -test('should not run this test', function() { +test('should not run this test', function () { (0).should.equal(1, 'this test should have been skipped'); }); -test.only('should run this test', function() { +test.only('should run this test', function () { (0).should.equal(0, 'this .only test should run'); }); -test('should run this test, not (includes the title of the .only test)', function() { +test('should run this test, not (includes the title of the .only test)', function () { (0).should.equal(1, 'this test should have been skipped'); }); // Mark suite suite.only('should run all tests in this suite'); -test('should run this test #1', function() { +test('should run this test #1', function () { (true).should.equal(true); }); -test('should run this test #2', function() { +test('should run this test #2', function () { (true).should.equal(true); }); -test('should run this test #3', function() { +test('should run this test #3', function () { (true).should.equal(true); }); // Unmark this suite suite('should not run any of this suite\'s tests'); -test('should not run this test', function() { +test('should not run this test', function () { (false).should.equal(true); }); -test('should not run this test', function() { +test('should not run this test', function () { (false).should.equal(true); }); -test('should not run this test', function() { +test('should not run this test', function () { (false).should.equal(true); }); // Mark test as `only` override the suite behavior suite.only('should run only tests that marked as `only`'); -test('should not run this test #1', function() { +test('should not run this test #1', function () { (false).should.equal(true); }); -test.only('should not run this test #2', function() { +test.only('should not run this test #2', function () { (true).should.equal(true); }); -test('should not run this test #3', function() { +test('should not run this test #3', function () { (false).should.equal(true); }); -test.only('should not run this test #4', function() { +test.only('should not run this test #4', function () { (true).should.equal(true); -});
\ No newline at end of file +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/misc/only/tdd.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/tdd.spec.js new file mode 100644 index 0000000000..da5f45b198 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/misc/only/tdd.spec.js @@ -0,0 +1,127 @@ +'use strict'; + +suite('should only run .only test in this tdd suite', function () { + test('should not run this test', function () { + (0).should.equal(1, 'this test should have been skipped'); + }); + test.only('should run this test', function () { + (0).should.equal(0, 'this .only test should run'); + }); + test('should run this test, not (includes the title of the .only test)', function () { + (0).should.equal(1, 'this test should have been skipped'); + }); +}); + +suite('should not run this suite', function () { + test('should not run this test', function () { + (true).should.equal(false); + }); + + test('should not run this test', function () { + (true).should.equal(false); + }); + + test('should not run this test', function () { + (true).should.equal(false); + }); +}); + +suite.only('should run all tests in this tdd suite', function () { + test('should run this test #1', function () { + (true).should.equal(true); + }); + + test('should run this test #2', function () { + (1).should.equal(1); + }); + + test('should run this test #3', function () { + ('foo').should.equal('foo'); + }); +}); + +suite('should run only suites that marked as `only`', function () { + suite.only('should run all this tdd suite', function () { + test('should run this test #1', function () { + (true).should.equal(true); + }); + + test('should run this test #2', function () { + (true).should.equal(true); + }); + }); + + suite('should not run this suite', function () { + test('should not run this test', function () { + (true).should.equal(false); + }); + }); +}); + +// Nested situation +suite('should not run parent tests', function () { + test('should not run this test', function () { + (true).should.equal(false); + }); + suite('and not the child tests too', function () { + test('should not run this test', function () { + (true).should.equal(false); + }); + suite.only('but run all the tests in this suite', function () { + test('should run this test #1', function () { + (true).should.equal(true); + }); + test('should run this test #2', function () { + (true).should.equal(true); + }); + }); + }); +}); + +// mark test as `only` override the suite behavior +suite.only('should run only tests that marked as `only`', function () { + test('should not run this test #1', function () { + (false).should.equal(true); + }); + + test.only('should run this test #2', function () { + (true).should.equal(true); + }); + + test('should not run this test #3', function () { + (false).should.equal(true); + }); + + test.only('should run this test #4', function () { + (true).should.equal(true); + }); +}); + +suite.only('Should run only test cases that mark as only', function () { + test.only('should runt his test', function () { + (true).should.equal(true); + }); + + test('should not run this test', function () { + (false).should.equal(true); + }); + + suite('should not run this suite', function () { + test('should not run this test', function () { + (false).should.equal(true); + }); + }); +}); + +// Root Suite +test.only('#Root-Suite, should run this test-case #1', function () { + (true).should.equal(true); +}); + +test.only('#Root-Suite, should run this test-case #2', function () { + (true).should.equal(true); +}); + +test('#Root-Suite, should not run this test', function () { + (false).should.equal(true); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/overspecified-async.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/overspecified-async.spec.js index 2844920379..0f9b6c9ff5 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/overspecified-async.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/overspecified-async.spec.js @@ -1,5 +1,7 @@ -describe('overspecified asynchronous resolution method', function() { - it('should fail when multiple methods are used', function(done) { +'use strict'; + +describe('overspecified asynchronous resolution method', function () { + it('should fail when multiple methods are used', function (done) { setTimeout(done, 0); // uncomment diff --git a/tests/lib/mocha-3.1.2/test/acceptance/require/a.js b/tests/lib/mocha-3.1.2/test/acceptance/require/a.js new file mode 100644 index 0000000000..949b8af2f0 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/require/a.js @@ -0,0 +1,4 @@ +'use strict'; + +global.required = (global.required || []); +global.required.push('a.js'); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/require/b.coffee b/tests/lib/mocha-3.1.2/test/acceptance/require/b.coffee index 045cc7591b..045cc7591b 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/require/b.coffee +++ b/tests/lib/mocha-3.1.2/test/acceptance/require/b.coffee diff --git a/tests/lib/mocha-3.1.2/test/acceptance/require/c.js b/tests/lib/mocha-3.1.2/test/acceptance/require/c.js new file mode 100644 index 0000000000..4d68dc4549 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/require/c.js @@ -0,0 +1,4 @@ +'use strict'; + +global.required = (global.required || []); +global.required.push('c.js'); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/require/d.coffee b/tests/lib/mocha-3.1.2/test/acceptance/require/d.coffee index d5ebbf60ed..d5ebbf60ed 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/require/d.coffee +++ b/tests/lib/mocha-3.1.2/test/acceptance/require/d.coffee diff --git a/tests/lib/mocha-3.1.0/test/acceptance/require/require.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/require/require.spec.js index 22570e62ff..f959a859a8 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/require/require.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/require/require.spec.js @@ -1,9 +1,11 @@ -describe('require test', function(){ - it('should require args in order', function(){ +'use strict'; + +describe('require test', function () { + it('should require args in order', function () { var req = global.required; expect(req.indexOf('a.js')).to.equal(0); expect(req.indexOf('b.coffee')).to.equal(1); expect(req.indexOf('c.js')).to.equal(2); expect(req.indexOf('d.coffee')).to.equal(3); - }) + }); }); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/required-tokens.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/required-tokens.spec.js index 6944cee40c..2b44dee59b 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/required-tokens.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/required-tokens.spec.js @@ -1,3 +1,5 @@ +'use strict'; + var assert = require('assert'); var describe = require('../..').describe; var it = require('../..').it; @@ -6,5 +8,5 @@ describe('using imported describe', function () { it('using imported it', function (done) { assert.ok(true); done(); - }) -}) + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/root.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/root.spec.js new file mode 100644 index 0000000000..abd8d4192e --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/root.spec.js @@ -0,0 +1,13 @@ +'use strict'; + +var calls = []; + +before(function () { + calls.push('before'); +}); + +describe('root', function () { + it('should be a valid suite', function () { + expect(calls).to.eql(['before']); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/test.coffee b/tests/lib/mocha-3.1.2/test/acceptance/test.coffee index b8e309f515..b8e309f515 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/test.coffee +++ b/tests/lib/mocha-3.1.2/test/acceptance/test.coffee diff --git a/tests/lib/mocha-3.1.0/test/acceptance/test.foo b/tests/lib/mocha-3.1.2/test/acceptance/test.foo index d00491fd7e..d00491fd7e 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/test.foo +++ b/tests/lib/mocha-3.1.2/test/acceptance/test.foo diff --git a/tests/lib/mocha-3.1.0/test/acceptance/throw.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/throw.spec.js index 46cfbad6ad..68e8cd2c1d 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/throw.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/throw.spec.js @@ -1,3 +1,7 @@ +'use strict'; + +/* eslint no-throw-literal: off */ + var Suite = require('../../lib/suite'); var Test = require('../../lib/test'); var Runner = require('../../lib/runner'); @@ -5,34 +9,33 @@ var Runner = require('../../lib/runner'); describe('a test that throws', function () { var suite, runner; - beforeEach(function(){ + beforeEach(function () { suite = new Suite('Suite', 'root'); runner = new Runner(suite); - }) - - describe('undefined', function (){ - it('should not pass if throwing sync and test is sync', function(done) { - var test = new Test('im sync and throw undefined sync', function(){ + }); + + describe('undefined', function () { + it('should not pass if throwing sync and test is sync', function (done) { + var test = new Test('im sync and throw undefined sync', function () { throw undefined; }); suite.addTest(test); runner = new Runner(suite); - runner.on('end', function(){ + runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); done(); }); runner.run(); - }) + }); - it('should not pass if throwing sync and test is async', function(done){ - var test = new Test('im async and throw undefined sync', function(done2){ + it('should not pass if throwing sync and test is async', function (done) { + var test = new Test('im async and throw undefined sync', function (done2) { throw undefined; - process.nexTick(done2); }); suite.addTest(test); runner = new Runner(suite); - runner.on('end', function(){ + runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); done(); @@ -40,47 +43,45 @@ describe('a test that throws', function () { runner.run(); }); - it('should not pass if throwing async and test is async', function(done){ - var test = new Test('im async and throw undefined async', function(done2){ - process.nexTick(function(){ + it('should not pass if throwing async and test is async', function (done) { + var test = new Test('im async and throw undefined async', function (done2) { + process.nexTick(function () { throw undefined; - done2(); }); }); suite.addTest(test); runner = new Runner(suite); - runner.on('end', function(){ + runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); done(); }); runner.run(); - }) - }) + }); + }); - describe('null', function (){ - it('should not pass if throwing sync and test is sync', function(done) { - var test = new Test('im sync and throw null sync', function(){ + describe('null', function () { + it('should not pass if throwing sync and test is sync', function (done) { + var test = new Test('im sync and throw null sync', function () { throw null; }); suite.addTest(test); runner = new Runner(suite); - runner.on('end', function(){ + runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); done(); }); runner.run(); - }) + }); - it('should not pass if throwing sync and test is async', function(done){ - var test = new Test('im async and throw null sync', function(done2){ + it('should not pass if throwing sync and test is async', function (done) { + var test = new Test('im async and throw null sync', function (done2) { throw null; - process.nexTick(done2); }); suite.addTest(test); runner = new Runner(suite); - runner.on('end', function(){ + runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); done(); @@ -88,21 +89,20 @@ describe('a test that throws', function () { runner.run(); }); - it('should not pass if throwing async and test is async', function(done){ - var test = new Test('im async and throw null async', function(done2){ - process.nexTick(function(){ + it('should not pass if throwing async and test is async', function (done) { + var test = new Test('im async and throw null async', function (done2) { + process.nexTick(function () { throw null; - done2(); }); }); suite.addTest(test); runner = new Runner(suite); - runner.on('end', function(){ + runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); done(); }); runner.run(); - }) - }) -}) + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/acceptance/timeout.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/timeout.spec.js new file mode 100644 index 0000000000..b3fc632a0d --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/acceptance/timeout.spec.js @@ -0,0 +1,79 @@ +'use strict'; + +describe('timeouts', function () { + beforeEach(function (done) { + // uncomment + // setTimeout(done, 3000); + done(); + }); + + it('should error on timeout', function (done) { + // uncomment + // setTimeout(done, 3000); + done(); + }); + + it('should allow overriding per-test', function (done) { + this.timeout(1000); + setTimeout(function () { + done(); + }, 300); + }); + + describe('disabling', function () { + it('should allow overriding per-test', function (done) { + this.enableTimeouts(false); + this.timeout(1); + setTimeout(done, 2); + }); + + it('should work with timeout(0)', function (done) { + this.timeout(0); + setTimeout(done, 1); + }); + + describe('using beforeEach', function () { + beforeEach(function () { + this.timeout(0); + }); + + it('should work with timeout(0)', function (done) { + setTimeout(done, 1); + }); + }); + + describe('using before', function () { + before(function () { + this.timeout(0); + }); + + it('should work with timeout(0)', function (done) { + setTimeout(done, 1); + }); + }); + + describe('using enableTimeouts(false)', function () { + this.timeout(4); + + it('should suppress timeout(4)', function (done) { + // The test is in the before() call. + this.enableTimeouts(false); + setTimeout(done, 50); + }); + }); + + describe('suite-level', function () { + this.timeout(0); + + it('should work with timeout(0)', function (done) { + setTimeout(done, 1); + }); + + describe('nested suite', function () { + it('should work with timeout(0)', function (done) { + setTimeout(done, 1); + }); + }); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/acceptance/utils.spec.js b/tests/lib/mocha-3.1.2/test/acceptance/utils.spec.js index cab0f42b01..545bdfd265 100644 --- a/tests/lib/mocha-3.1.0/test/acceptance/utils.spec.js +++ b/tests/lib/mocha-3.1.2/test/acceptance/utils.spec.js @@ -1,100 +1,103 @@ +'use strict'; + var utils = require('../../lib/utils'); var toISOString = require('../../lib/to-iso-string'); var JSON = require('json3'); describe('lib/utils', function () { describe('clean', function () { - it("should format a single line test function", function () { + 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;"); + 'function () {', + ' var a = 1;', + '}' + ].join('\n'); + expect(utils.clean(fn)).to.equal('var a = 1;'); }); - it("should format a multi line test indented with spaces", function () { + it('should format a multi line test indented with spaces', function () { // and no new lines after curly braces, shouldn't matter var fn = [ - "function(){ var a = 1;" - , " var b = 2;" // this one has more spaces - , " var c = 3; }" - ].join("\n"); - expect(utils.clean(fn)).to.equal("var a = 1;\n var b = 2;\nvar c = 3;"); + 'function(){ var a = 1;', + // this one has more spaces + ' var b = 2;', + ' var c = 3; }' + ].join('\n'); + 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 () { + it('should format a multi line test indented with tabs', function () { var fn = [ - "function (arg1, arg2) {" - , "\tif (true) {" - , "\t\tvar a = 1;" - , "\t}" - , "}" - ].join("\n"); - expect(utils.clean(fn)).to.equal("if (true) {\n\tvar a = 1;\n}"); + 'function (arg1, arg2) {', + '\tif (true) {', + '\t\tvar a = 1;', + '\t}', + '}' + ].join('\n'); + expect(utils.clean(fn)).to.equal('if (true) {\n\tvar a = 1;\n}'); }); - it("should format functions saved in windows style - spaces", function () { + it('should format functions saved in windows style - spaces', function () { var fn = [ - "function (one) {" - , " do {" - , ' "nothing";' - , " } while (false);" - , ' }' - ].join("\r\n"); + 'function (one) {', + ' do {', + ' "nothing";', + ' } while (false);', + ' }' + ].join('\r\n'); expect(utils.clean(fn)).to.equal('do {\n "nothing";\n} while (false);'); }); - it("should format functions saved in windows style - tabs", function () { + it('should format functions saved in windows style - tabs', function () { var fn = [ - "function ( ) {" - , "\tif (false) {" - , "\t\tvar json = {" - , '\t\t\tone : 1' - , '\t\t};' - , "\t}" - , "}" - ].join("\r\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 () { + 'function ( ) {', + '\tif (false) {', + '\t\tvar json = {', + '\t\t\tone : 1', + '\t\t};', + '\t}', + '}' + ].join('\r\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 () { var fn = [ - "() => {", - " var a = 1;", - "}" - ].join("\n"); - expect(utils.clean(fn)).to.equal("var a = 1;"); + '() => {', + ' var a = 1;', + '}' + ].join('\n'); + 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()"); + it('should format es6 arrow functions with implicit return', function () { + var fn = '() => foo()'; + expect(utils.clean(fn)).to.equal('foo()'); }); }); - describe('stringify', function(){ - + describe('stringify', function () { var stringify = utils.stringify; - it('should return an object representation of a string created with a String constructor', function() { + it('should return an object representation of a string created with a String constructor', function () { + /* eslint no-new-wrappers: off */ expect(stringify(new String('foo'))).to.equal('{\n "0": "f"\n "1": "o"\n "2": "o"\n}'); }); - it('should return Buffer with .toJSON representation', function() { + it('should return Buffer with .toJSON representation', function () { expect(stringify(new Buffer([0x01]))).to.equal('[\n 1\n]'); expect(stringify(new Buffer([0x01, 0x02]))).to.equal('[\n 1\n 2\n]'); expect(stringify(new Buffer('ABCD'))).to.equal('[\n 65\n 66\n 67\n 68\n]'); }); - it('should return Date object with .toISOString() + string prefix', function() { + it('should return Date object with .toISOString() + string prefix', function () { expect(stringify(new Date(0))).to.equal('[Date: ' + shimToISOString(new Date(0)) + ']'); var date = new Date(); // now expect(stringify(date)).to.equal('[Date: ' + shimToISOString(date) + ']'); - function shimToISOString(date) { + function shimToISOString (date) { if (date.toISOString) { return date.toISOString(); } else { @@ -103,32 +106,32 @@ describe('lib/utils', function () { } }); - it('should return invalid Date object with .toString() + string prefix', function() { + it('should return invalid Date object with .toString() + string prefix', function () { expect(stringify(new Date(''))).to.equal('[Date: ' + new Date('').toString() + ']'); }); - describe('#Number', function() { - it('should show the handle -0 situations', function() { + describe('#Number', function () { + it('should show the handle -0 situations', function () { expect(stringify(-0)).to.eql('-0'); expect(stringify(0)).to.eql('0'); expect(stringify('-0')).to.eql('"-0"'); }); - it('should work well with `NaN` and `Infinity`', function() { + it('should work well with `NaN` and `Infinity`', function () { expect(stringify(NaN)).to.equal('NaN'); expect(stringify(Infinity)).to.equal('Infinity'); expect(stringify(-Infinity)).to.equal('-Infinity'); }); - it('floats and ints', function() { + it('floats and ints', function () { expect(stringify(1)).to.equal('1'); expect(stringify(1.2)).to.equal('1.2'); expect(stringify(1e9)).to.equal('1000000000'); }); }); - describe('canonicalize example', function() { - it('should represent the actual full result', function() { + describe('canonicalize example', function () { + it('should represent the actual full result', function () { var expected = { str: 'string', int: 90, @@ -138,148 +141,155 @@ describe('lib/utils', function () { undef: undefined, regex: /^[a-z|A-Z]/, date: new Date(0), - func: function() {}, + func: function () {}, infi: Infinity, nan: NaN, zero: -0, buffer: new Buffer([0x01, 0x02]), - array: [1,2,3], + array: [1, 2, 3], empArr: [], - matrix: [[1], [2,3,4] ], + matrix: [[1], + [ + 2, + 3, + 4 + ] + ], object: { a: 1, b: 2 }, canObj: { a: { b: 1, c: 2 }, b: {} }, empObj: {} }; expected.circular = expected; // Make `Circular` situation - var actual = ['{' - , ' "array": [' - , ' 1' - , ' 2' - , ' 3' - , ' ]' - , ' "boolean": false' - , ' "buffer": [Buffer: [' - , ' 1' - , ' 2' - , ' ]]' - , ' "canObj": {' - , ' "a": {' - , ' "b": 1' - , ' "c": 2' - , ' }' - , ' "b": {}' - , ' }' - , ' "circular": [Circular]' - , ' "date": [Date: 1970-01-01T00:00:00.000Z]' - , ' "empArr": []' - , ' "empObj": {}' - , ' "float": 9.99' - , ' "func": [Function]' - , ' "infi": Infinity' - , ' "int": 90' - , ' "matrix": [' - , ' [' - , ' 1' - , ' ]' - , ' [' - , ' 2' - , ' 3' - , ' 4' - , ' ]' - , ' ]' - , ' "nan": NaN' - , ' "nil": [null]' - , ' "object": {' - , ' "a": 1' - , ' "b": 2' - , ' }' - , ' "regex": /^[a-z|A-Z]/' - , ' "str": "string"' - , ' "undef": [undefined]' - , ' "zero": -0' - , '}'].join('\n'); + var actual = [ + '{', + ' "array": [', + ' 1', + ' 2', + ' 3', + ' ]', + ' "boolean": false', + ' "buffer": [Buffer: [', + ' 1', + ' 2', + ' ]]', + ' "canObj": {', + ' "a": {', + ' "b": 1', + ' "c": 2', + ' }', + ' "b": {}', + ' }', + ' "circular": [Circular]', + ' "date": [Date: 1970-01-01T00:00:00.000Z]', + ' "empArr": []', + ' "empObj": {}', + ' "float": 9.99', + ' "func": [Function]', + ' "infi": Infinity', + ' "int": 90', + ' "matrix": [', + ' [', + ' 1', + ' ]', + ' [', + ' 2', + ' 3', + ' 4', + ' ]', + ' ]', + ' "nan": NaN', + ' "nil": [null]', + ' "object": {', + ' "a": 1', + ' "b": 2', + ' }', + ' "regex": /^[a-z|A-Z]/', + ' "str": "string"', + ' "undef": [undefined]', + ' "zero": -0', + '}' + ].join('\n'); expect(stringify(expected)).to.equal(actual); }); }); - it('should canonicalize the object', function(){ + it('should canonicalize the object', function () { var travis = { name: 'travis', age: 24 }; var travis2 = { age: 24, name: 'travis' }; expect(stringify(travis)).to.equal(stringify(travis2)); }); - it('should handle circular structures in objects', function(){ + it('should handle circular structures in objects', function () { var travis = { name: 'travis' }; travis.whoami = travis; expect(stringify(travis)).to.equal('{\n "name": "travis"\n "whoami": [Circular]\n}'); }); - it('should handle circular structures in arrays', function(){ + it('should handle circular structures in arrays', function () { var travis = ['travis']; travis.push(travis); expect(stringify(travis)).to.equal('[\n "travis"\n [Circular]\n]'); }); - it('should handle circular structures in functions', function(){ + it('should handle circular structures in functions', function () { var travis = function () {}; travis.fn = travis; expect(stringify(travis)).to.equal('{\n "fn": [Circular]\n}'); }); - it('should handle various non-undefined, non-null, non-object, non-array, non-date, and non-function values', function () { - var regexp = new RegExp("(?:)"), - regExpObj = { regexp: regexp }, - regexpString = '/(?:)/'; + var regexp = new RegExp('(?:)'); + var regExpObj = {regexp: regexp}; + var regexpString = '/(?:)/'; expect(stringify(regExpObj)).to.equal('{\n "regexp": ' + regexpString + '\n}'); expect(stringify(regexp)).to.equal(regexpString); - var number = 1, - numberObj = { number: number }, - numberString = '1'; + var number = 1; + var numberObj = {number: number}; + var numberString = '1'; expect(stringify(numberObj)).to.equal('{\n "number": ' + number + '\n}'); expect(stringify(number)).to.equal(numberString); - var boolean = false, - booleanObj = { boolean: boolean }, - booleanString = 'false'; + var boolean = false; + var booleanObj = {boolean: boolean}; + var booleanString = 'false'; expect(stringify(booleanObj)).to.equal('{\n "boolean": ' + boolean + '\n}'); expect(stringify(boolean)).to.equal(booleanString); - var string = 'sneepy', - stringObj = { string: string }; + var string = 'sneepy'; + var stringObj = {string: string}; expect(stringify(stringObj)).to.equal('{\n "string": "' + string + '"\n}'); expect(stringify(string)).to.equal(JSON.stringify(string)); - var nullValue = null, - nullObj = { 'null': null }, - nullString = '[null]'; + var nullValue = null; + var nullObj = {'null': null}; + var nullString = '[null]'; expect(stringify(nullObj)).to.equal('{\n "null": [null]\n}'); expect(stringify(nullValue)).to.equal(nullString); }); it('should handle arrays', function () { - var array = ['dave', 'dave', 'dave', 'dave'], - arrayObj = {array: array}, - arrayString = ' "dave"\n "dave"\n "dave"\n "dave"' + var array = ['dave', 'dave', 'dave', 'dave']; + var arrayObj = {array: array}; + var arrayString = ' "dave"\n "dave"\n "dave"\n "dave"'; expect(stringify(arrayObj)).to.equal('{\n "array": [\n' + arrayString + '\n ]\n}'); expect(stringify(array)).to.equal('[' + arrayString.replace(/\s+/g, '\n ') + '\n]'); }); it('should handle functions', function () { - var fn = function() {}, - fnObj = {fn: fn}, - fnString = '[Function]'; + var fn = function () {}; + var fnObj = {fn: fn}; + var fnString = '[Function]'; expect(stringify(fnObj)).to.equal('{\n "fn": ' + fnString + '\n}'); expect(stringify(fn)).to.equal('[Function]'); @@ -296,17 +306,17 @@ describe('lib/utils', function () { }); it('should handle non-empty arrays', function () { - expect(stringify(['a', 'b', 'c'])).to.equal('[\n "a"\n "b"\n "c"\n]') + expect(stringify(['a', 'b', 'c'])).to.equal('[\n "a"\n "b"\n "c"\n]'); }); it('should handle empty functions (with no properties)', function () { - expect(stringify(function(){})).to.equal('[Function]'); - expect(stringify({foo: function() {}})).to.equal('{\n "foo": [Function]\n}'); - expect(stringify({foo: function() {}, bar: 'baz'})).to.equal('{\n "bar": "baz"\n "foo": [Function]\n}'); + expect(stringify(function () {})).to.equal('[Function]'); + expect(stringify({foo: function () {}})).to.equal('{\n "foo": [Function]\n}'); + expect(stringify({foo: function () {}, bar: 'baz'})).to.equal('{\n "bar": "baz"\n "foo": [Function]\n}'); }); it('should handle functions w/ properties', function () { - var fn = function(){}; + var fn = function () {}; fn.bar = 'baz'; expect(stringify(fn)).to.equal('{\n "bar": "baz"\n}'); expect(stringify({foo: fn})).to.equal('{\n "foo": {\n "bar": "baz"\n }\n}'); @@ -354,23 +364,25 @@ describe('lib/utils', function () { it('should handle Symbol', function () { var symbol = Symbol('value'); expect(stringify(symbol)).to.equal('Symbol(value)'); - expect(stringify({symbol: symbol})).to.equal('{\n "symbol": Symbol(value)\n}') + expect(stringify({symbol: symbol})).to.equal('{\n "symbol": Symbol(value)\n}'); }); } it('should handle length properties that cannot be coerced to a number', function () { expect(stringify({length: {nonBuiltinProperty: 0}})).to.equal('{\n "length": {\n "nonBuiltinProperty": 0\n }\n}'); - expect(stringify({length: "a string where length should be"})).to.equal('{\n "length": "a string where length should be"\n}'); + expect(stringify({length: 'a string where length should be'})).to.equal('{\n "length": "a string where length should be"\n}'); }); }); describe('type', function () { + /* eslint no-extend-native: off */ + var type = utils.type; var toString = Object.prototype.toString; - beforeEach(function() { + beforeEach(function () { // some JS engines such as PhantomJS 1.x exhibit this behavior - Object.prototype.toString = function() { + Object.prototype.toString = function () { if (this === global) { return '[object DOMWindow]'; } diff --git a/tests/lib/mocha-3.1.0/test/browser-fixtures/bdd.fixture.js b/tests/lib/mocha-3.1.2/test/browser-fixtures/bdd.fixture.js index 72b4a8a47c..d19993676a 100644 --- a/tests/lib/mocha-3.1.0/test/browser-fixtures/bdd.fixture.js +++ b/tests/lib/mocha-3.1.2/test/browser-fixtures/bdd.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + /* eslint-env browser */ window.mocha.timeout(200) diff --git a/tests/lib/mocha-3.1.0/test/browser-fixtures/exports.fixture.js b/tests/lib/mocha-3.1.2/test/browser-fixtures/exports.fixture.js index 32c26a12ff..97b8b97cbe 100644 --- a/tests/lib/mocha-3.1.0/test/browser-fixtures/exports.fixture.js +++ b/tests/lib/mocha-3.1.2/test/browser-fixtures/exports.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + /* eslint-env browser */ window.mocha.timeout(200) diff --git a/tests/lib/mocha-3.1.0/test/browser-fixtures/qunit.fixture.js b/tests/lib/mocha-3.1.2/test/browser-fixtures/qunit.fixture.js index 8804d0b994..a3fd887940 100644 --- a/tests/lib/mocha-3.1.0/test/browser-fixtures/qunit.fixture.js +++ b/tests/lib/mocha-3.1.2/test/browser-fixtures/qunit.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + /* eslint-env browser */ window.mocha.timeout(200) diff --git a/tests/lib/mocha-3.1.0/test/browser-fixtures/tdd.fixture.js b/tests/lib/mocha-3.1.2/test/browser-fixtures/tdd.fixture.js index 997a47dc18..0c36f0c54b 100644 --- a/tests/lib/mocha-3.1.0/test/browser-fixtures/tdd.fixture.js +++ b/tests/lib/mocha-3.1.2/test/browser-fixtures/tdd.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + /* eslint-env browser */ window.mocha.timeout(200) diff --git a/tests/lib/mocha-3.1.2/test/browser/array.spec.js b/tests/lib/mocha-3.1.2/test/browser/array.spec.js new file mode 100644 index 0000000000..edf66ac458 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/browser/array.spec.js @@ -0,0 +1,39 @@ +'use strict'; + +describe('Array', function () { + describe('#push()', function () { + it('should append a value', function () { + var arr = []; + arr.push('foo'); + arr.push('bar'); + arr.push('baz'); + assert(arr[0] === 'foo'); // to test indentation + assert(arr[1] === 'bar'); + assert(arr[2] === 'baz'); + }); + + it('should return the length', function () { + var arr = []; + assert(arr.push('foo') === 1); + assert(arr.push('bar') === 2); + assert(arr.push('baz') === 3); + }); + }); +}); + +describe('Array', function () { + describe('#pop()', function () { + it('should remove and return the last value', function () { + var arr = [1, 2, 3]; + assert(arr.pop() === 3); + assert(arr.pop() === 2); + assert(arr.pop() === -1); + }); + + it('should adjust .length', function () { + var arr = [1, 2, 3]; + arr.pop(); + assert(arr.length === 2); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/browser/grep.html b/tests/lib/mocha-3.1.2/test/browser/grep.html index 0ba47c8533..0ba47c8533 100644 --- a/tests/lib/mocha-3.1.0/test/browser/grep.html +++ b/tests/lib/mocha-3.1.2/test/browser/grep.html diff --git a/tests/lib/mocha-3.1.2/test/browser/grep.spec.js b/tests/lib/mocha-3.1.2/test/browser/grep.spec.js new file mode 100644 index 0000000000..6c5a83aeb5 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/browser/grep.spec.js @@ -0,0 +1,110 @@ +'use strict'; + +// numbers +describe('21', function () { + it('1', function () { + assert(true); + }); + it('2', function () { + assert(true); + }); +}); +// symbols +describe('@Array', function () { + it('.pop()', function () { + assert(true); + }); + it('.push()', function () { + assert(true); + }); + it('.length', function () { + assert(true); + }); +}); + +describe('@Function', function () { + it('.call()', function () { + assert(true); + }); + it('.apply()', function () { + assert(true); + }); + it('.length', function () { + assert(true); + }); + it('.name', function () { + assert(true); + }); + it('.prototype', function () { + assert(true); + }); +}); + +// url with hashtags +describe('#Services', function () { + describe('#http', function () { + it('.createClient()', function () { + assert(true); + }); + it('.Server()', function () { + assert(true); + }); + }); + describe('#crypto', function () { + it('.randomBytes()', function () { + assert(true); + }); + it('.Hmac()', function () { + assert(true); + }); + }); +}); + +// Uppercase +describe('CONSTANTS', function () { + it('.STATUS_CODES', function () { + assert(true); + }); +}); + +// Dates +describe('Date:', function () { + it('01/02/2015', function () { + assert(true); + }); + it('01/03/2015', function () { + assert(true); + }); + it('01/06/2015', function () { + assert(true); + }); +}); + +// etc.. +describe('booking/summary', function () { + it('should be run last', function () { + assert(true); + }); +}); + +describe('component/booking/summary', function () { + it('should be run second', function () { + assert(true); + }); +}); + +describe('component/booking/intro', function () { + it('should be run first', function () { + assert(true); + }); +}); + +describe('contains numbers', function () { + it('should run if the number 92 matching', function () { + assert(true); + }); + + it('should run if the number 8 matching', function () { + assert(true); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/browser/index.html b/tests/lib/mocha-3.1.2/test/browser/index.html index 9200b977e5..9200b977e5 100644 --- a/tests/lib/mocha-3.1.0/test/browser/index.html +++ b/tests/lib/mocha-3.1.2/test/browser/index.html diff --git a/tests/lib/mocha-3.1.0/test/browser/large.html b/tests/lib/mocha-3.1.2/test/browser/large.html index 1804b3a000..1804b3a000 100644 --- a/tests/lib/mocha-3.1.0/test/browser/large.html +++ b/tests/lib/mocha-3.1.2/test/browser/large.html diff --git a/tests/lib/mocha-3.1.0/test/browser/large.spec.js b/tests/lib/mocha-3.1.2/test/browser/large.spec.js index 56757eae27..7dfa62f2a2 100644 --- a/tests/lib/mocha-3.1.0/test/browser/large.spec.js +++ b/tests/lib/mocha-3.1.2/test/browser/large.spec.js @@ -1,37 +1,38 @@ +'use strict'; + var n = 30; while (n--) { - describe('Array ' + n, function(){ + describe('Array ' + n, function () { var arr; - beforeEach(function(){ - arr = [1,2,3]; - }) + beforeEach(function () { + arr = [1, 2, 3]; + }); - describe('#indexOf()', function(){ - it('should return -1 when the value is not present', function(){ - assert(-1 == arr.indexOf(5)); - }) + describe('#indexOf()', function () { + it('should return -1 when the value is not present', function () { + assert(arr.indexOf(5) === -1); + }); - it('should return the correct index when the value is present', function(done){ - assert(0 == arr.indexOf(1)); - assert(1 == arr.indexOf(2)); + it('should return the correct index when the value is present', function (done) { + assert(arr.indexOf(1) === 0); + assert(arr.indexOf(2) === 1); done(); - }) - }) - }) + }); + }); + }); } -describe('something', function(){ - it('should provide a useful error', function(done){ - setTimeout(function(){ +describe('something', function () { + it('should provide a useful error', function (done) { + setTimeout(function () { throw new Error('boom'); - done(); }, 1); - }) + }); - it('should provide an even better error on phantomjs', function(done){ - setTimeout(function(){ - var AssertionError = function(message, actual, expected) { + it('should provide an even better error on phantomjs', function (done) { + setTimeout(function () { + var AssertionError = function (message, actual, expected) { this.message = message; this.actual = actual; this.expected = expected; @@ -44,5 +45,5 @@ describe('something', function(){ mocha.throwError(new AssertionError('kabooom', 'text with a typo', 'text without a typo')); done(); }, 1); - }) -}) + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/browser/multiple-done.spec.js b/tests/lib/mocha-3.1.2/test/browser/multiple-done.spec.js index d8a9d49ae2..ddb536735e 100644 --- a/tests/lib/mocha-3.1.0/test/browser/multiple-done.spec.js +++ b/tests/lib/mocha-3.1.2/test/browser/multiple-done.spec.js @@ -1,16 +1,18 @@ -describe('Multiple Done calls', function(){ - it('should report an error if done was called more than once', function(done){ +'use strict'; + +describe('Multiple Done calls', function () { + it('should report an error if done was called more than once', function (done) { done(); done(); - }) + }); it('should report an error if an exception happened async after done was called', function (done) { done(); setTimeout(done, 50); - }) + }); - it('should report an error if an exception happened after done was called', function(done){ + it('should report an error if an exception happened after done was called', function (done) { done(); - throw new Error("thrown error"); - }) -}) + throw new Error('thrown error'); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/browser/opts.html b/tests/lib/mocha-3.1.2/test/browser/opts.html index ec49a418fc..ec49a418fc 100644 --- a/tests/lib/mocha-3.1.0/test/browser/opts.html +++ b/tests/lib/mocha-3.1.2/test/browser/opts.html diff --git a/tests/lib/mocha-3.1.2/test/browser/opts.spec.js b/tests/lib/mocha-3.1.2/test/browser/opts.spec.js new file mode 100644 index 0000000000..7b93f22615 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/browser/opts.spec.js @@ -0,0 +1,7 @@ +'use strict'; + +describe('Options', function () { + it('should set timeout value', function () { + assert(this.test._timeout === 1500); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/browser/stack-trace.html b/tests/lib/mocha-3.1.2/test/browser/stack-trace.html index 0f267dab98..0f267dab98 100644 --- a/tests/lib/mocha-3.1.0/test/browser/stack-trace.html +++ b/tests/lib/mocha-3.1.2/test/browser/stack-trace.html diff --git a/tests/lib/mocha-3.1.2/test/browser/stack-trace.spec.js b/tests/lib/mocha-3.1.2/test/browser/stack-trace.spec.js new file mode 100644 index 0000000000..a4801bf32f --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/browser/stack-trace.spec.js @@ -0,0 +1,22 @@ +'use strict'; +describe('Stack trace', function () { + it('should prettify the stack-trace', function () { + var err = new Error(); + // We do this fake stack-trace because we under development, + // and our root isn't `node_modules`, `bower` or `components` + err.stack = [ + 'Error: failed', + 'at assert (stack-trace.html:11:30)', + 'at Context.<anonymous> (stack-trace.js:5:5)', + 'at callFn (http://localhost:63342/node_modules/mocha.js:4546:21)', + 'at Test.require.register.Runnable.run (http://localhost:63342/node_modules/mocha.js:4539:7)', + 'at Runner.require.register.Runner.runTest (http://localhost:63342/node_modules/mocha.js:4958:10)', + 'at http://localhost:63342/bower_components/mocha.js:5041:12', + 'at next (http://localhost:63342/bower_components/mocha.js:4883:14)', + 'at http://localhost:63342/bower_components/mocha.js:4893:7', + 'at next (http://localhost:63342/bower_components/mocha.js:4828:23)', + 'at http://localhost:63342/bower_components/mocha.js:4860:5' + ].join('\n'); + assert(false, err); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/browser/ui.html b/tests/lib/mocha-3.1.2/test/browser/ui.html index 071c7798a0..071c7798a0 100644 --- a/tests/lib/mocha-3.1.0/test/browser/ui.html +++ b/tests/lib/mocha-3.1.2/test/browser/ui.html diff --git a/tests/lib/mocha-3.1.0/test/browser/ui.spec.js b/tests/lib/mocha-3.1.2/test/browser/ui.spec.js index 48236e9497..159cab6d95 100644 --- a/tests/lib/mocha-3.1.0/test/browser/ui.spec.js +++ b/tests/lib/mocha-3.1.2/test/browser/ui.spec.js @@ -1,10 +1,12 @@ +'use strict'; + // test titles containing regex-conflicting characters // leading $ -describe('$.jQuery', function() { +describe('$.jQuery', function () { // parens describe('.on()', function () { - it('should set an event', function() { + it('should set an event', function () { assert(true); }); }); @@ -18,14 +20,14 @@ describe('$.jQuery', function() { // another generic describe block to verify it is absent // when greeping on $.jQuery -describe('@Array', function() { - it('.pop()', function() { +describe('@Array', function () { + it('.pop()', function () { assert(true); }); - it('.push()', function() { + it('.push()', function () { assert(true); }); - it('.length', function() { + it('.length', function () { assert(true); }); }); diff --git a/tests/lib/mocha-3.1.0/test/color.spec.js b/tests/lib/mocha-3.1.2/test/color.spec.js index 5ee46e71c4..bffd30e6eb 100644 --- a/tests/lib/mocha-3.1.0/test/color.spec.js +++ b/tests/lib/mocha-3.1.2/test/color.spec.js @@ -1,13 +1,15 @@ +'use strict'; + var assert = require('assert'); -var child_process = require('child_process'); +var childProcess = require('child_process'); var path = require('path'); -describe('Mocha', function() { +describe('Mocha', function () { this.timeout(2000); - it('should not output colors to pipe', function(cb) { + it('should not output colors to pipe', function (cb) { var command = [path.join('bin', 'mocha'), '--grep', 'missing-test']; - child_process.execFile(process.execPath, command, function(err, stdout, stderr) { + childProcess.execFile(process.execPath, command, function (err, stdout, stderr) { if (err) return cb(err); assert(stdout.indexOf('[90m') === -1); diff --git a/tests/lib/mocha-3.1.0/test/compiler/foo.js b/tests/lib/mocha-3.1.2/test/compiler/foo.js index b13101a77b..753d08e740 100644 --- a/tests/lib/mocha-3.1.0/test/compiler/foo.js +++ b/tests/lib/mocha-3.1.2/test/compiler/foo.js @@ -1,8 +1,10 @@ +'use strict'; + var fs = require('fs'); -require.extensions['.foo'] = function(module, filename) { +require.extensions['.foo'] = function (module, filename) { var content; content = fs.readFileSync(filename, 'utf8'); - var test = 'describe("custom compiler",function(){ it("should work",function() { ' - + content + '.should.eql(1); }); });'; + var test = 'describe("custom compiler",function(){ it("should work",function() { ' + + content + '.should.eql(1); }); });'; return module._compile(test, filename); }; diff --git a/tests/lib/mocha-3.1.0/test/grep.spec.js b/tests/lib/mocha-3.1.2/test/grep.spec.js index bbc5c55eba..dd21cf0090 100644 --- a/tests/lib/mocha-3.1.0/test/grep.spec.js +++ b/tests/lib/mocha-3.1.2/test/grep.spec.js @@ -1,48 +1,50 @@ +'use strict'; + var Mocha = require('../'); -describe('Mocha', function(){ - describe('"grep" option', function(){ - it('should add a RegExp to the mocha.options object', function(){ +describe('Mocha', function () { + describe('"grep" option', function () { + it('should add a RegExp to the mocha.options object', function () { var mocha = new Mocha({ grep: /foo.*/ }); mocha.options.grep.toString().should.equal('/foo.*/'); }); - it('should convert string to a RegExp', function(){ + it('should convert string to a RegExp', function () { var mocha = new Mocha({ grep: 'foo.*' }); mocha.options.grep.toString().should.equal('/foo.*/'); }); }); - describe('"fgrep" option', function(){ - it('should escape and convert string to a RegExp', function(){ + describe('"fgrep" option', function () { + it('should escape and convert string to a RegExp', function () { var mocha = new Mocha({ fgrep: 'foo.*' }); mocha.options.grep.toString().should.equal('/foo\\.\\*/'); }); }); - describe('.grep()', function() { + describe('.grep()', function () { // Test helper - function testGrep(mocha) { - return function testGrep(grep, expected) { + function testGrep (mocha) { + return function testGrep (grep, expected) { mocha.grep(grep); mocha.options.grep.toString().should.equal(expected); - } + }; } - it('should add a RegExp to the mocha.options object', function() { - var test = testGrep(new Mocha); + it('should add a RegExp to the mocha.options object', function () { + var test = testGrep(new Mocha()); test(/foo/, '/foo/'); }); - it('should convert grep string to a RegExp', function() { - var test = testGrep(new Mocha); + it('should convert grep string to a RegExp', function () { + var test = testGrep(new Mocha()); test('foo', '/foo/'); test('^foo.*bar$', '/^foo.*bar$/'); test('^@.*(?=\\(\\)$)', '/^@.*(?=\\(\\)$)/'); }); - it('should covert grep regex-like string to a RegExp', function() { - var test = testGrep(new Mocha); + it('should covert grep regex-like string to a RegExp', function () { + var test = testGrep(new Mocha()); test('/foo/', '/foo/'); // Keep the flags test('/baz/i', '/baz/i'); @@ -50,14 +52,14 @@ describe('Mocha', function(){ test('/^foo(.*)bar/g', '/^foo(.*)bar/g'); }); - it('should return it\'s parent Mocha object for chainability', function(){ - var mocha = new Mocha; + it('should return it\'s parent Mocha object for chainability', function () { + var mocha = new Mocha(); mocha.grep().should.equal(mocha); }); }); - describe('"invert" option', function(){ - it('should add a Boolean to the mocha.options object', function(){ + describe('"invert" option', function () { + it('should add a Boolean to the mocha.options object', function () { var mocha = new Mocha({ invert: true }); mocha.options.invert.should.be.ok; }); diff --git a/tests/lib/mocha-3.1.2/test/hook-async.spec.js b/tests/lib/mocha-3.1.2/test/hook-async.spec.js new file mode 100644 index 0000000000..a03821e32c --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/hook-async.spec.js @@ -0,0 +1,135 @@ +'use strict'; + +describe('async', function () { + var calls = []; + + before(function () { + calls.push('root before all'); + }); + + after(function () { + calls.push('root after all'); + calls.should.eql([ + 'root before all', + 'before all', + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two', + 'two', + 'after', + 'after test two passed', + 'parent after', + 'parent before', + 'before', + 'before test three', + 'three', + 'after', + 'after test three passed', + 'parent after', + 'after all', + 'root after all' + ]); + }); + + beforeEach(function () { + calls.push('parent before'); + }); + + afterEach(function () { + calls.push('parent after'); + }); + + describe('hooks', function () { + before(function () { + calls.push('before all'); + }); + + after(function () { + calls.push('after all'); + }); + + beforeEach(function (done) { + var ctx = this; + process.nextTick(function () { + calls.push('before'); + if (ctx.currentTest) { + calls.push('before test ' + ctx.currentTest.title); + } + done(); + }); + }); + + it('one', function (done) { + calls.should.eql([ + 'root before all', + 'before all', + 'parent before', + 'before', + 'before test one' + ]); + calls.push('one'); + process.nextTick(done); + }); + + it('two', function () { + calls.should.eql([ + 'root before all', + 'before all', + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two' + ]); + calls.push('two'); + }); + + it('three', function () { + calls.should.eql([ + 'root before all', + 'before all', + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two', + 'two', + 'after', + 'after test two passed', + 'parent after', + 'parent before', + 'before', + 'before test three' + ]); + calls.push('three'); + }); + + afterEach(function (done) { + var ctx = this; + process.nextTick(function () { + calls.push('after'); + if (ctx.currentTest) { + calls.push('after test ' + ctx.currentTest.title + ' ' + ctx.currentTest.state); + } + done(); + }); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/hook-sync-nested.spec.js b/tests/lib/mocha-3.1.2/test/hook-sync-nested.spec.js new file mode 100644 index 0000000000..3f1929f547 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/hook-sync-nested.spec.js @@ -0,0 +1,104 @@ +'use strict'; + +describe('serial', function () { + describe('nested', function () { + var calls = []; + + beforeEach(function () { + calls.push('parent before'); + if (this.currentTest) { + calls.push('parent before test ' + this.currentTest.title); + } + }); + + afterEach(function () { + calls.push('parent after'); + if (this.currentTest) { + calls.push('parent after test ' + this.currentTest.title + ' ' + this.currentTest.state); + } + }); + + it('foo', function () { + calls.should.eql([ + 'parent before', + 'parent before test foo' + ]); + calls.push('foo'); + }); + + it('bar', function () { + calls.should.eql([ + 'parent before', + 'parent before test foo', + 'foo', + 'parent after', + 'parent after test foo passed', + 'parent before', + 'parent before test bar' + ]); + }); + + describe('hooks', function () { + beforeEach(function () { + calls.push('before'); + if (this.currentTest) { + calls.push('before test ' + this.currentTest.title); + } + }); + + it('one', function () { + calls.should.eql([ + 'parent before', + 'parent before test foo', + 'foo', + 'parent after', + 'parent after test foo passed', + 'parent before', + 'parent before test bar', + 'parent after', + 'parent after test bar passed', + 'parent before', + 'parent before test one', + 'before', + 'before test one' + ]); + calls.push('one'); + }); + + it('two', function () { + calls.should.eql([ + 'parent before', + 'parent before test foo', + 'foo', + 'parent after', + 'parent after test foo passed', + 'parent before', + 'parent before test bar', + 'parent after', + 'parent after test bar passed', + 'parent before', + 'parent before test one', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent after test one passed', + 'parent before', + 'parent before test two', + 'before', + 'before test two' + ]); + calls.push('two'); + }); + + afterEach(function () { + calls.push('after'); + if (this.currentTest) { + calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state); + } + }); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/hook-sync.spec.js b/tests/lib/mocha-3.1.2/test/hook-sync.spec.js new file mode 100644 index 0000000000..b1138a6db8 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/hook-sync.spec.js @@ -0,0 +1,103 @@ +'use strict'; + +describe('serial', function () { + var calls = []; + + beforeEach(function () { + calls.push('parent before'); + }); + + afterEach(function () { + calls.push('parent after'); + }); + + describe('hooks', function () { + beforeEach(function () { + calls.push('before'); + if (this.currentTest) { + calls.push('before test ' + this.currentTest.title); + } + }); + + it('one', function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one' + ]); + calls.push('one'); + }); + + it('two', function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two' + ]); + calls.push('two'); + }); + + it('three', function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two', + 'two', + 'after', + 'after test two passed', + 'parent after', + 'parent before', + 'before', + 'before test three' + ]); + calls.push('three'); + }); + + afterEach(function () { + calls.push('after'); + if (this.currentTest) { + calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state); + } + }); + + after(function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two', + 'two', + 'after', + 'after test two passed', + 'parent after', + 'parent before', + 'before', + 'before test three', + 'three', + 'after', + 'after test three passed', + 'parent after' + ]); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/hook-timeout.spec.js b/tests/lib/mocha-3.1.2/test/hook-timeout.spec.js new file mode 100644 index 0000000000..c16c3011fb --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/hook-timeout.spec.js @@ -0,0 +1,10 @@ +'use strict'; + +before(function (done) { + this.timeout(100); + setTimeout(done, 50); +}); + +it('should work', function (done) { + done(); +}); diff --git a/tests/lib/mocha-3.1.0/test/http-meta-2.spec.js b/tests/lib/mocha-3.1.2/test/http-meta-2.spec.js index fe9662b2e6..4530969041 100644 --- a/tests/lib/mocha-3.1.0/test/http-meta-2.spec.js +++ b/tests/lib/mocha-3.1.2/test/http-meta-2.spec.js @@ -1,10 +1,12 @@ +'use strict'; + var http = require('http'); var PORT = 8899; -var server = http.createServer(function(req, res){ - var accept = req.headers.accept || '' - , json = ~accept.indexOf('json'); +var server = http.createServer(function (req, res) { + var accept = req.headers.accept || ''; + var json = ~accept.indexOf('json'); switch (req.url) { case '/': @@ -18,43 +20,43 @@ var server = http.createServer(function(req, res){ } break; } -}) +}); -function get(url) { - var fields - , expected - , header = {}; +function get (url) { + var fields; + var expected; + var header = {}; - function request(done) { - http.get({ path: url, port: PORT, headers: header }, function(res){ + function request (done) { + http.get({ path: url, port: PORT, headers: header }, function (res) { var buf = ''; res.should.have.property('statusCode', 200); res.setEncoding('utf8'); - res.on('data', function(chunk){ buf += chunk }); - res.on('end', function(){ + res.on('data', function (chunk) { buf += chunk; }); + res.on('end', function () { buf.should.equal(expected); done(); }); - }) + }); } return { - set: function(field, val){ + set: function (field, val) { header[field] = val; return this; }, should: { - respond: function(body){ - fields = Object.keys(header).map(function(field){ + respond: function (body) { + fields = Object.keys(header).map(function (field) { return field + ': ' + header[field]; }).join(', '); expected = body; - describe('GET ' + url, function(){ + describe('GET ' + url, function () { this.timeout(500); if (fields) { - describe('when given ' + fields, function(){ + describe('when given ' + fields, function () { it('should respond with "' + body + '"', request); }); } else { @@ -66,26 +68,25 @@ function get(url) { }; } -describe('http server', function(){ - - before(function(done) { +describe('http server', function () { + before(function (done) { server.listen(PORT, done); }); - after(function() { + after(function () { server.close(); }); get('/') .should - .respond('hello') + .respond('hello'); get('/users') .should - .respond('tobi, loki, jane') + .respond('tobi, loki, jane'); get('/users') .set('Accept', 'application/json') .should - .respond('["tobi","loki","jane"]') -}) + .respond('["tobi","loki","jane"]'); +}); diff --git a/tests/lib/mocha-3.1.0/test/http-meta.spec.js b/tests/lib/mocha-3.1.2/test/http-meta.spec.js index 5d1fb6750b..c92dbd2307 100644 --- a/tests/lib/mocha-3.1.0/test/http-meta.spec.js +++ b/tests/lib/mocha-3.1.2/test/http-meta.spec.js @@ -1,10 +1,12 @@ +'use strict'; + var http = require('http'); var PORT = 8889; -var server = http.createServer(function(req, res){ - var accept = req.headers.accept || '' - , json = ~accept.indexOf('json'); +var server = http.createServer(function (req, res) { + var accept = req.headers.accept || ''; + var json = ~accept.indexOf('json'); switch (req.url) { case '/': @@ -20,42 +22,44 @@ var server = http.createServer(function(req, res){ } }); - -function get(url, body, header) { - return function(done){ - http.get({ path: url, port: PORT, headers: header || {}}, function(res){ +function get (url, body, header) { + return function (done) { + http.get({ + path: url, + port: PORT, + headers: header || {} + }, function (res) { var buf = ''; res.should.have.property('statusCode', 200); res.setEncoding('utf8'); - res.on('data', function(chunk){ buf += chunk }); - res.on('end', function(){ + res.on('data', function (chunk) { buf += chunk; }); + res.on('end', function () { buf.should.equal(body); done(); }); - }) - } + }); + }; } describe('http requests', function () { - - before(function(done) { + before(function (done) { server.listen(PORT, done); }); - after(function() { + after(function () { server.close(); }); describe('GET /', function () { it('should respond with hello', - get('/', 'hello')) - }) + get('/', 'hello')); + }); - describe('GET /users', function(){ + describe('GET /users', function () { it('should respond with users', - get('/users', 'tobi, loki, jane')) + get('/users', 'tobi, loki, jane')); it('should respond with users', - get('/users', '["tobi","loki","jane"]', { Accept: 'application/json' })) - }) -}) + get('/users', '["tobi","loki","jane"]', { Accept: 'application/json' })); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/diffs.spec.js b/tests/lib/mocha-3.1.2/test/integration/diffs.spec.js index b779b84ada..7d620e7489 100644 --- a/tests/lib/mocha-3.1.0/test/integration/diffs.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/diffs.spec.js @@ -1,23 +1,25 @@ -var assert = require('assert'); -var helpers = require('./helpers'); -var run = helpers.runMocha; -var fs = require('fs'); +'use strict'; + +var assert = require('assert'); +var helpers = require('./helpers'); +var run = helpers.runMocha; +var fs = require('fs'); var getDiffs = helpers.getDiffs; -function getExpectedOutput() { +function getExpectedOutput () { var output = fs.readFileSync('test/integration/fixtures/diffs/output', 'UTF8'); // Diffs are delimited in file by "// DIFF" - return output.split(/\s*\/\/ DIFF/).slice(1).map(function(diff) { + return output.split(/\s*\/\/ DIFF/).slice(1).map(function (diff) { return diff.split('\n').filter(Boolean).join('\n'); }); } -describe('diffs', function() { +describe('diffs', function () { var diffs, expected; - before(function(done) { - run('diffs/diffs.fixture.js', ['-C'], function(err, res) { + before(function (done) { + run('diffs/diffs.fixture.js', ['-C'], function (err, res) { expected = getExpectedOutput(); diffs = getDiffs(res.output); done(err); @@ -36,8 +38,8 @@ describe('diffs', function() { 'should work with objects', 'should show value diffs and not be affected by commas', 'should display diff by data and not like an objects' - ].forEach(function(title, i) { - it(title, function() { + ].forEach(function (title, i) { + it(title, function () { assert.equal(diffs[i], expected[i]); }); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/cascade.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/cascade.fixture.js index 10b1c37ffd..259c81af2d 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/cascade.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/cascade.fixture.js @@ -1,55 +1,57 @@ -describe('one', function() { - before(function() { +'use strict'; + +describe('one', function () { + before(function () { console.log('before one'); }); - after(function() { + after(function () { console.log('after one'); }); - beforeEach(function() { + beforeEach(function () { console.log(' before each one'); }); - afterEach(function() { + afterEach(function () { console.log(' after each one'); }); - describe('two', function() { - before(function() { + describe('two', function () { + before(function () { console.log(' before two'); }); - after(function() { + after(function () { console.log(' after two'); }); - beforeEach(function() { + beforeEach(function () { console.log(' before each two'); }); - afterEach(function() { + afterEach(function () { console.log(' after each two'); }); - describe('three', function() { - before(function() { + describe('three', function () { + before(function () { console.log(' before three'); }); - after(function() { + after(function () { console.log(' after three'); }); - beforeEach(function() { + beforeEach(function () { console.log(' before each three'); }); - afterEach(function() { + afterEach(function () { console.log(' after each three'); }); - it('should three', function() { + it('should three', function () { console.log(' TEST three'); }); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/diffs.css.in b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.in index 09a3ca5363..09a3ca5363 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/diffs.css.in +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.in diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/diffs.css.out b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.out index 53b3ec906e..53b3ec906e 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/diffs.css.out +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.out diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/diffs.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.fixture.js index cf538fd777..50ea00bee0 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/diffs.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.fixture.js @@ -1,58 +1,87 @@ -var fs = require('fs'); -var assert = require('assert'); -var cssin = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.in', 'ascii'); +'use strict'; + +var fs = require('fs'); +var cssin = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.in', 'ascii'); var cssout = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.out', 'ascii'); -describe('diffs', function() { +describe('diffs', function () { var actual, expected; - it('should display a diff for small strings', function() { + it('should display a diff for small strings', function () { actual = 'foo rar baz'; expected = 'foo bar baz'; actual.should.equal(expected); }); - it('should display a diff of canonicalized objects', function() { + it('should display a diff of canonicalized objects', function () { actual = { name: 'travis j', age: 23 }; expected = { age: 23, name: 'travis' }; actual.should.equal(expected); }); - it('should display a diff for medium strings', function() { + it('should display a diff for medium strings', function () { actual = 'foo bar baz\nfoo rar baz\nfoo bar raz'; expected = 'foo bar baz\nfoo bar baz\nfoo bar baz'; actual.should.equal(expected); }); - it('should display a diff for entire object dumps', function() { - actual = { name: 'joel', age: 30, address: {city: 'new york', country: 'usa' }}; - expected = { name: 'joe', age: 30, address: {city: 'new york', country: 'us' }}; + it('should display a diff for entire object dumps', function () { + actual = { + name: 'joel', + age: 30, + address: { + city: 'new york', + country: 'usa' + } + }; + expected = { + name: 'joe', + age: 30, + address: { + city: 'new york', + country: 'us' + } + }; actual.should.equal(expected); }); - it('should display a diff for multi-line strings', function() { - actual = 'one two three\nfour zzzz six\nseven eight nine'; + it('should display a diff for multi-line strings', function () { + actual = 'one two three\nfour zzzz six\nseven eight nine'; expected = 'one two three\nfour five six\nseven eight nine'; actual.should.equal(expected); }); - it('should display a diff for entire object dumps', function() { - actual = { name: 'joel', age: 30, address: {city: 'new york', country: 'usa' }}; - expected = { name: 'joe', age: 30, address: {city: 'new york', country: 'us' }} + it('should display a diff for entire object dumps', function () { + actual = { + name: 'joel', + age: 30, + address: { + city: 'new york', + country: 'usa' + } + }; + expected = { + name: 'joe', + age: 30, + address: { + city: 'new york', + country: 'us' + } + }; actual.should.equal(expected); }); - it('should display a full-comparison with escaped special characters', function() { - actual = 'one\ttab\ntwo\t\t\ttabs'; + it('should display a full-comparison with escaped special characters', function () { + actual = 'one\ttab\ntwo\t\t\ttabs'; expected = 'one\ttab\ntwo\t\ttabs'; actual.should.equal(expected); }); - it('should display a word diff for large strings', function() { + it('should display a word diff for large strings', function () { cssin.should.equal(cssout); }); - it('should work with objects', function() { + it('should work with objects', function () { actual = { name: 'tobi', species: 'ferret', @@ -70,13 +99,13 @@ describe('diffs', function() { actual.should.eql(expected); }); - it('should show value diffs and not be affected by commas', function() { + it('should show value diffs and not be affected by commas', function () { actual = { a: 123 }; expected = { a: 123, b: 456 }; actual.should.equal(expected); }); - it('should display diff by data and not like an objects', function() { + it('should display diff by data and not like an objects', function () { actual = new Buffer([0x01]); expected = new Buffer([0x02]); actual.should.equal(expected); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/output b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/output index bf56a96397..bf56a96397 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/diffs/output +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/output diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/after-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-async-error.fixture.js index dc55537a60..f3dfe7e1ae 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/after-hook-async-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-async-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { after(function (done) { console.log('after'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/after-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-error.fixture.js index e84856e433..7fc258f46d 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/after-hook-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { after(function () { console.log('after'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js index d4f4c9bdd9..442ad9321f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { afterEach(function (done) { console.log('after'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js index 9d28632fa3..5fb9a36c8d 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { afterEach(function () { console.log('after'); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js new file mode 100644 index 0000000000..04801c1946 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js @@ -0,0 +1,13 @@ +'use strict'; + +describe('spec 1', function () { + it('should not blame me', function () { }); +}); +describe('spec 2', function () { + before(function (done) { + process.nextTick(function () { + throw new Error('before hook error'); + }); + }); + it('skipped'); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error.fixture.js index 10ea95156b..2530eec783 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-async-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { before(function (done) { console.log('before'); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js new file mode 100644 index 0000000000..64df731573 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js @@ -0,0 +1,11 @@ +'use strict'; + +describe('spec 1', function () { + it('should not blame me', function () { }); +}); +describe('spec 2', function () { + before(function () { + throw new Error('before hook error'); + }); + it('skipped'); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error.fixture.js index b3d6ea6640..547e54a243 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/before-hook-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { before(function () { console.log('before'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js index a34ed755e2..6ce27784a6 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { beforeEach(function (done) { console.log('before'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js index bd84e8fe74..4c0ab2f237 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + describe('spec 1', function () { beforeEach(function () { console.log('before'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js index 93ace7ff0d..858bbb3c5e 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + before(function () { console.log('root before'); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/multiple-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-error.fixture.js index 53d167b1cf..085978ef79 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/hooks/multiple-hook-error.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-error.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + before(function () { console.log('root before'); }); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js new file mode 100644 index 0000000000..1e1bc71a16 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js @@ -0,0 +1,12 @@ +'use strict'; + +describe('suite', function () { + before(function (done) { + setTimeout(done, 10); + setTimeout(done, 30); + }); + + it('test1', function (done) { + setTimeout(done, 50); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js new file mode 100644 index 0000000000..32de2bf442 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js @@ -0,0 +1,16 @@ +'use strict'; + +describe('suite', function () { + beforeEach(function (done) { + setTimeout(done, 10); + setTimeout(done, 20); + }); + + it('test1', function (done) { + setTimeout(done, 50); + }); + + it('test2', function (done) { + setTimeout(done, 50); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js new file mode 100644 index 0000000000..a8ae6d1ac4 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js @@ -0,0 +1,12 @@ +'use strict'; + +describe('suite', function () { + it('test1', function (done) { + done(); + setTimeout(done, 10); + }); + + it('test2', function (done) { + setTimeout(done, 20); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done.fixture.js index 63a704061c..f1b471c678 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/multiple-done.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done.fixture.js @@ -1,3 +1,5 @@ +'use strict'; + // The suite below should result in an additional error, but does // not. Uncomment once this bug is resolved. @@ -10,8 +12,8 @@ // it('test', function() {}); // }); -it('should fail in a test-case', function(done) { - process.nextTick(function(){ +it('should fail in a test-case', function (done) { + process.nextTick(function () { done(); done(); }); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js new file mode 100644 index 0000000000..d5ba2b37a0 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js @@ -0,0 +1,5 @@ +'use strict'; + +it('should pass', function (done) { + done(); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js new file mode 100644 index 0000000000..512fd0e4db --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js @@ -0,0 +1,3 @@ +'use strict'; + +it('throws an error', function () {}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js new file mode 100644 index 0000000000..5095e63158 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js @@ -0,0 +1,23 @@ +'use strict'; + +describe('suite1', function () { + it('should display this spec', function () {}); + + it('should only display this error', function (done) { + throw new Error('this should be displayed'); + }); + + it('should not display this error', function (done) { + throw new Error('this should not be displayed'); + }); +}); + +describe('suite2', function () { + before(function (done) { + throw new Error('this hook should not be displayed'); + }); + + it('should not display this error', function (done) { + throw new Error('this should not be displayed'); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js new file mode 100644 index 0000000000..644cbc0281 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js @@ -0,0 +1,8 @@ +'use strict'; + +setTimeout(function () { + throw new Error('oops'); + /* eslint no-unreachable: off */ + it('test', function () {}); + run(); +}, 100); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/delay.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay.fixture.js index a8bf2d4112..b2d49217db 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/delay.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay.fixture.js @@ -1,9 +1,11 @@ +'use strict'; + var assert = require('assert'); -var delay = 500; +var delay = 500; -setTimeout(function() { - describe('delayed execution', function() { - it('should have no effect if attempted twice in the same suite', function() { +setTimeout(function () { + describe('delayed execution', function () { + it('should have no effect if attempted twice in the same suite', function () { assert(true); run(); assert(true); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js new file mode 100644 index 0000000000..0939d084ec --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js @@ -0,0 +1,19 @@ +'use strict'; + +describe('grep', function () { + describe('Match', function () { + it('should run', function () {}); + it('should also run', function () {}); + }); + + describe('match', function () { + it('should run', function () {}); + it('should also run', function () {}); + }); + + describe('fail', function () { + it('should not be ran', function () { + throw new Error('Spec should not run'); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js new file mode 100644 index 0000000000..39323f3567 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js @@ -0,0 +1,72 @@ +'use strict'; + +describe.only('should run this suite', function () { + it('should run this test', function () {}); + + it('should run this test', function () {}); + + it('should run this test', function () {}); +}); + +describe('should not run this suite', function () { + it('should not run this test', function () { + (true).should.equal(false); + }); + + it('should not run this test', function () { + (true).should.equal(false); + }); + + it('should not run this test', function () { + (true).should.equal(false); + }); +}); + +describe.only('should run this suite too', function () { + describe('should run this nested suite', function () { + it('should run this test', function () {}); + + it('should run this test', function () {}); + + it('should run this test', function () {}); + }); +}); + +describe.only('should run this suite, even', function () { + describe('should run this nested suite, even', function () { + describe('should run this doubly-nested suite!', function () { + it('should run this test', function () {}); + + it('should run this test', function () {}); + + it('should run this test', function () {}); + }); + }); +}); + +describe('should run this suite with an exclusive test', function () { + it.only('should run this test', function () {}); + + describe('should not run this nested suite', function () { + describe.only('should not run this doubly-nested suite', function () { + it('should not run this test', function () {}); + + it('should not run this test', function () {}); + + it('should not run this test', function () {}); + }); + }); +}); + +describe('should run this suite with an exclusive test (reverse order)', function () { + describe('should not run this nested suite', function () { + describe.only('should not run this doubly-nested suite', function () { + it('should not run this test', function () {}); + + it('should not run this test', function () {}); + + it('should not run this test', function () {}); + }); + }); + it.only('should run this test', function () {}); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js new file mode 100644 index 0000000000..8bc598030d --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js @@ -0,0 +1,27 @@ +'use strict'; + +suite.only('should run all tests in this suite'); + +test('should run this test #1', function () {}); + +test('should run this test #2', function () {}); + +test('should run this test #3', function () {}); + +test('should run this test #4', function () {}); + +test('should run this test #5', function () {}); + +suite('should not run any of this suite\'s tests'); + +test('should not run this test', function () { + (false).should.equal(true); +}); + +test('should not run this test', function () { + (false).should.equal(true); +}); + +test('should not run this test', function () { + (false).should.equal(true); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js new file mode 100644 index 0000000000..987ee6bfba --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js @@ -0,0 +1,37 @@ +'use strict'; + +suite.only('should run all tests in this tdd suite', function () { + test('should run this test #1', function () {}); + + test('should run this test #2', function () {}); + + test('should run this test #3', function () {}); + + test('should run this test #4', function () {}); +}); + +suite('should not run this suite', function () { + test('should not run this test', function () { + (true).should.equal(false); + }); + + test('should not run this test', function () { + (true).should.equal(false); + }); + + test('should not run this test', function () { + (true).should.equal(false); + }); +}); + +suite.only('should run this suite too', function () { + suite('should run this nested suite', function () { + test('should run this test', function () {}); + + test('should run this test', function () {}); + + test('should run this test', function () {}); + + test('should run this test', function () {}); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/retries.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/retries.fixture.js index b2f76e12ea..8d2b0a40b6 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/retries.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/retries.fixture.js @@ -1,4 +1,6 @@ -describe('retries', function() { +'use strict'; + +describe('retries', function () { it('should fail', function () { throw new Error('retry failure'); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/sort-alpha.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-alpha.fixture.js index 7a5302994f..dd74303163 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/options/sort-alpha.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-alpha.fixture.js @@ -1,5 +1,7 @@ -describe('alpha', function(){ - it('should be executed first', function(){ +'use strict'; + +describe('alpha', function () { + it('should be executed first', function () { if (global.beta) { throw new Error('alpha was not executed first'); } diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js new file mode 100644 index 0000000000..56da4a6523 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js @@ -0,0 +1,7 @@ +'use strict'; + +describe('beta', function () { + it('should be executed second', function () { + global.beta = 1; + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js new file mode 100644 index 0000000000..baf142026d --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js @@ -0,0 +1,13 @@ +'use strict'; + +var assert = require('assert'); + +describe('suite', function () { + it('test1', function () { + assert(true); + }); + + it('test2', function () { + assert(true); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js new file mode 100644 index 0000000000..efeaa93899 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js @@ -0,0 +1,18 @@ +'use strict'; + +describe('skip in before', function () { + before(function (done) { + var self = this; + setTimeout(function () { + self.skip(); + }, 50); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js new file mode 100644 index 0000000000..d6225564ba --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js @@ -0,0 +1,18 @@ +'use strict'; + +describe('skip in beforeEach', function () { + beforeEach(function (done) { + var self = this; + setTimeout(function () { + self.skip(); + }, 50); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js new file mode 100644 index 0000000000..44707b026c --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js @@ -0,0 +1,14 @@ +'use strict'; + +describe('skip in test', function () { + it('should skip async', function (done) { + var self = this; + setTimeout(function () { + self.skip(); + }, 50); + }); + + it('should run other tests in the suite', function () { + // Do nothing + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js new file mode 100644 index 0000000000..5e3b208efa --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js @@ -0,0 +1,15 @@ +'use strict'; + +describe('skip in before', function () { + before(function () { + this.skip(); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js new file mode 100644 index 0000000000..0bd155ba55 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js @@ -0,0 +1,15 @@ +'use strict'; + +describe('skip in beforeEach', function () { + beforeEach(function () { + this.skip(); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); + + it('should never run this test', function () { + throw new Error('never thrown'); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js new file mode 100644 index 0000000000..1d22f0b77d --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js @@ -0,0 +1,12 @@ +'use strict'; + +describe('skip in test', function () { + it('should skip immediately', function () { + this.skip(); + throw new Error('never thrown'); + }); + + it('should run other tests in the suite', function () { + // Do nothing + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js new file mode 100644 index 0000000000..d750fcad1a --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js @@ -0,0 +1,5 @@ +'use strict'; + +describe('suite', function () { + it('pending spec'); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js new file mode 100644 index 0000000000..8867369546 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js @@ -0,0 +1,5 @@ +'use strict'; + +test('pass', function () { + // pass +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/1794/simple-ui.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/simple-ui.js index 1fdf33d665..5cfde0465f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/1794/simple-ui.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/simple-ui.js @@ -1,13 +1,14 @@ -var path = '../../../../../lib/', - Mocha = require(path + 'mocha'); - Suite = require(path + 'suite'), - Test = require(path + 'test'); +'use strict'; + +var path = '../../../../../lib/'; +var Mocha = require(path + 'mocha'); +var Test = require(path + 'test'); /** * A simple UI that only exposes a single function: test */ -module.exports = Mocha.interfaces['simple-ui'] = function(suite) { - suite.on('pre-require', function(context, file, mocha) { +module.exports = Mocha.interfaces['simple-ui'] = function (suite) { + suite.on('pre-require', function (context, file, mocha) { var common = require(path + 'interfaces/common')([suite], context); context.run = mocha.options.delay && common.runWithSuite(suite); @@ -16,7 +17,7 @@ module.exports = Mocha.interfaces['simple-ui'] = function(suite) { * Describes a specification or test-case with the given `title` * and callback `fn` acting as a thunk. */ - context.test = function(title, fn) { + context.test = function (title, fn) { var test = new Test(title, fn); test.file = file; suite.addTest(test); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js new file mode 100644 index 0000000000..e788278d6d --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js @@ -0,0 +1,17 @@ +'use strict'; + +it('test 1', function () { + console.log('testbody1'); + process.nextTick(function () { + throw new Error('Too bad'); + }); +}); + +it('test 2', function () { + console.log('testbody2'); +}); + +it('test 3', function () { + console.log('testbody3'); + throw new Error('OUCH'); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js new file mode 100644 index 0000000000..13ce053784 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js @@ -0,0 +1,22 @@ +'use strict'; + +/** + * This file should generate only one failure per spec for the thrown error. + * It should not report misleading 'multiple calls to done()'. + */ + +it('fails exactly once when a global error is thrown synchronously and done errors', function (done) { + setTimeout(function () { + done(new Error('test error')); + }, 1); // Not 0 - it will 'succeed', but won't test the breaking condition + + throw new Error('sync error'); +}); + +it('fails exactly once when a global error is thrown synchronously and done completes', function (done) { + setTimeout(function () { + done(); + }, 1); // Not 0 - it will 'succeed', but won't test the breaking condition + + throw new Error('sync error'); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-1991.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1991.fixture.js index 96860332a2..024f02519f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-1991.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1991.fixture.js @@ -1,7 +1,11 @@ -function MemoryLeak() { +'use strict'; + +/* eslint no-unused-vars: off */ + +function MemoryLeak () { this.myArr = []; for (var i = 0; i < 1000000; i++) { - this.myArr.push(i) + this.myArr.push(i); } } @@ -13,7 +17,6 @@ for (var i = 0; i < numOfTests; i += 1) { * if all the deferred functions references have not been cleared */ describe('Memory Leak Suite #' + i, function () { - // The <closureVar> variable will be accessed by the test below. // As long as those test's functions are // referenced in memory, the closure variable may not be garbage collected @@ -22,19 +25,19 @@ for (var i = 0; i < numOfTests; i += 1) { var closureVar; before(function () { - var x = closureVar ? 1 : 2 + var x = closureVar ? 1 : 2; }); after(function () { - var x = closureVar[0] + var x = closureVar[0]; }); beforeEach(function () { - var x = closureVar ? 1 : 2 + var x = closureVar ? 1 : 2; }); afterEach(function () { - var x = closureVar[0] + var x = closureVar[0]; }); it('access a variable via a closure', function () { @@ -42,6 +45,5 @@ for (var i = 0; i < numOfTests; i += 1) { this.timeout(1000); closureVar = new MemoryLeak(); }); - }); } diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2315.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2315.js index cdfb201059..fe18841d1c 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/regression/issue-2315.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2315.js @@ -1,3 +1,5 @@ +'use strict'; + describe('issue-2315: cannot read property currentRetry of undefined', function () { before(function () { process.nextTick(function () { diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js new file mode 100644 index 0000000000..b3770014dd --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('outer describe', function () { + it('should not run this test', function () {}); + describe('this suite should not run', function () { + it('should not run this test', function () {}); + }); + describe.only('this .only suite should run', function () { + describe('this suite should run', function () { + it('should run this test in a nested suite', function () {}); + }); + it('should run this test', function () {}); + }); + describe('this suite should not run', function () { + it('should not run this test', function () {}); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js new file mode 100644 index 0000000000..58f49cf846 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js @@ -0,0 +1,9 @@ +'use strict'; + +describe('outer describe', function () { + describe.only('outer describe.only', function () { + it.only('inner it.only', function () { + // should run and exit without error + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/async.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/async.fixture.js index 0e917e52f3..56d067fc05 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/async.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/async.fixture.js @@ -1,4 +1,6 @@ -describe('retries', function() { +'use strict'; + +describe('retries', function () { var times = 0; before(function () { console.log('before'); @@ -8,7 +10,7 @@ describe('retries', function() { console.log('after'); }); - beforeEach(function() { + beforeEach(function () { console.log('before each', times); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/early-pass.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/early-pass.fixture.js index 0010d120fa..ddad40399e 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/early-pass.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/early-pass.fixture.js @@ -1,8 +1,10 @@ -describe('retries', function() { +'use strict'; + +describe('retries', function () { this.retries(1); var times = 0; - it('should pass after 1 retry', function() { + it('should pass after 1 retry', function () { times++; if (times !== 2) { throw new Error('retry error ' + times); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/hooks.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/hooks.fixture.js index 47f6c6a1b7..b4fc081aaa 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/hooks.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/hooks.fixture.js @@ -1,4 +1,6 @@ -describe('retries', function() { +'use strict'; + +describe('retries', function () { var times = 0; before(function () { console.log('before'); @@ -8,7 +10,7 @@ describe('retries', function() { console.log('after'); }); - beforeEach(function() { + beforeEach(function () { console.log('before each', times); }); @@ -16,7 +18,7 @@ describe('retries', function() { console.log('after each', times); }); - it('should allow override and run appropriate hooks', function(){ + it('should allow override and run appropriate hooks', function () { this.retries(4); console.log('TEST', times); times++; diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/nested.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/nested.fixture.js index 43c40cb236..877d519d7f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/retries/nested.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/nested.fixture.js @@ -1,7 +1,9 @@ -describe('retries', function() { +'use strict'; + +describe('retries', function () { this.retries(3); describe('nested', function () { - it('should fail after only 1 retry', function(){ + it('should fail after only 1 retry', function () { this.retries(1); throw new Error('retry error'); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/suite/suite-no-callback.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-no-callback.fixture.js index de55b358a3..80d046438f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/suite/suite-no-callback.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-no-callback.fixture.js @@ -1 +1,3 @@ +'use strict'; + describe('a suite without a callback'); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/suite/suite-skipped-callback.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-callback.fixture.js index b30b67ee2e..6def25de7f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/suite/suite-skipped-callback.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-callback.fixture.js @@ -1 +1,3 @@ +'use strict'; + xdescribe('a pending suite with a callback', function () {}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js index c5bca84a47..e9381159bf 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js @@ -1 +1,3 @@ +'use strict'; + xdescribe('a pending suite without a callback'); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js new file mode 100644 index 0000000000..d237436811 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js @@ -0,0 +1,19 @@ +'use strict'; + +describe('timeout', function () { + this.timeout(1); + + it('should be honored with sync suites', function () { + sleep(2); + }); + + it('should be honored with async suites', function (done) { + sleep(2); + done(); + }); + + function sleep (ms) { + var start = Date.now(); + while (start + ms > Date.now()); + } +}); diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js new file mode 100644 index 0000000000..54f30c56e9 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js @@ -0,0 +1,15 @@ +'use strict'; + +describe('uncaught', function () { + beforeEach(function (done) { + process.nextTick(function () { + throw new Error('oh noes'); + }); + }); + + it('test', function (done) { + process.nextTick(function () { + throw new Error("I'm uncaught!"); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/integration/fixtures/uncaught.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught.fixture.js index 054d1d857b..6a2ded880c 100644 --- a/tests/lib/mocha-3.1.0/test/integration/fixtures/uncaught.fixture.js +++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught.fixture.js @@ -5,22 +5,18 @@ * Mocha is capable of detecting two distinct exceptions during test execution. */ -it('fails exactly once when a global error is thrown first', function(done) { - setTimeout(function() { +it('fails exactly once when a global error is thrown first', function (done) { + setTimeout(function () { throw new Error('global error'); - - setTimeout(function() { - done(new Error('test error')); - }, 0); }, 0); }); -it('fails exactly once when a global error is thrown second', function(done) { - setTimeout(function() { +it('fails exactly once when a global error is thrown second', function (done) { + setTimeout(function () { done(new Error('test error')); }, 0); - setTimeout(function() { + setTimeout(function () { throw new Error('global error'); }, 0); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/helpers.js b/tests/lib/mocha-3.1.2/test/integration/helpers.js index 2720eb3bda..7f6a608a6f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/helpers.js +++ b/tests/lib/mocha-3.1.2/test/integration/helpers.js @@ -1,5 +1,7 @@ +'use strict'; + var spawn = require('child_process').spawn; -var path = require('path'); +var path = require('path'); var fs = require('fs'); var baseReporter = require('../../lib/reporters/base'); @@ -24,13 +26,13 @@ module.exports = { * @param {array} args * @param {function} fn */ - runMocha: function(fixturePath, args, fn) { + runMocha: function (fixturePath, args, fn) { var path; path = resolveFixturePath(fixturePath); args = args || []; - invokeMocha(args.concat(['-C', path]), function(err, res) { + invokeMocha(args.concat(['-C', path]), function (err, res) { if (err) return fn(err); fn(null, getSummary(res)); @@ -57,19 +59,19 @@ module.exports = { * @param {array} args * @param {function} fn */ - runMochaFunction: function(fixture, args, fn) { + runMochaFunction: function (fixture, args, fn) { var path = resolveFixturePath(fixture.name + '.js' || 'tempfile.js'); args = args || []; var fixtureContent = 'var fn = ' + fixture.toString() + '; fn()'; fs.writeFileSync(path, fixtureContent, 'utf8'); - function cleanup() { + function cleanup () { fs.unlink(path); fn.apply(this, arguments); } - invokeMocha(args.concat(['-C', path]), function(err, res) { + invokeMocha(args.concat(['-C', path]), function (err, res) { if (err) { return cleanup(err); } @@ -86,13 +88,13 @@ module.exports = { * @param {array} args * @param {function} fn */ - runMochaJSON: function(fixturePath, args, fn) { + runMochaJSON: function (fixturePath, args, fn) { var path; path = resolveFixturePath(fixturePath); args = args || []; - invokeMocha(args.concat(['--reporter', 'json', path]), function(err, res) { + invokeMocha(args.concat(['--reporter', 'json', path]), function (err, res) { if (err) return fn(err); try { @@ -113,12 +115,12 @@ module.exports = { * @param {string} output * returns {string[]} */ - getDiffs: function(output) { + getDiffs: function (output) { var diffs, i, inDiff, inStackTrace; diffs = []; - output.split('\n').forEach(function(line) { - if (line.match(/^ \d+\)/)) { + output.split('\n').forEach(function (line) { + if (line.match(/^\s{2}\d+\)/)) { // New spec, e.g. "1) spec title" diffs.push([]); i = diffs.length - 1; @@ -140,7 +142,7 @@ module.exports = { }); // Ignore empty lines before/after diff - return diffs.map(function(diff) { + return diffs.map(function (diff) { return diff.slice(1, -3).join('\n'); }); }, @@ -151,14 +153,14 @@ module.exports = { splitRegExp: new RegExp('[\\n' + baseReporter.symbols.dot + ']+') }; -function invokeMocha(args, fn) { +function invokeMocha (args, fn) { var output, mocha, listener; output = ''; args = [path.join('bin', 'mocha')].concat(args); mocha = spawn(process.execPath, args); - listener = function(data) { + listener = function (data) { output += data; }; @@ -166,7 +168,7 @@ function invokeMocha(args, fn) { mocha.stderr.on('data', listener); mocha.on('error', fn); - mocha.on('close', function(code) { + mocha.on('close', function (code) { fn(null, { output: output.split('\n').join('\n'), code: code @@ -174,12 +176,12 @@ function invokeMocha(args, fn) { }); } -function resolveFixturePath(fixture) { +function resolveFixturePath (fixture) { return path.join('./test/integration/fixtures', fixture); } -function getSummary(res) { - return ['passing', 'pending', 'failing'].reduce(function(summary, type) { +function getSummary (res) { + return ['passing', 'pending', 'failing'].reduce(function (summary, type) { var pattern, match; pattern = new RegExp(' (\\d+) ' + type + '\\s'); diff --git a/tests/lib/mocha-3.1.0/test/integration/hook-err.spec.js b/tests/lib/mocha-3.1.2/test/integration/hook-err.spec.js index be18721f31..fbdd7e8e38 100644 --- a/tests/lib/mocha-3.1.0/test/integration/hook-err.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/hook-err.spec.js @@ -1,14 +1,16 @@ +'use strict'; + var assert = require('assert'); var runMocha = require('./helpers').runMocha; var splitRegExp = require('./helpers').splitRegExp; var bang = require('../../lib/reporters/base').symbols.bang; -describe('hook error handling', function() { +describe('hook error handling', function () { var lines; - describe('before hook error', function() { + describe('before hook error', function () { before(run('hooks/before-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['before', bang + 'test 3'] @@ -16,9 +18,9 @@ describe('hook error handling', function() { }); }); - describe('before hook error tip', function() { + describe('before hook error tip', function () { before(run('hooks/before-hook-error-tip.fixture.js', onlyErrorTitle)); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['1) spec 2 "before all" hook:'] @@ -26,9 +28,9 @@ describe('hook error handling', function() { }); }); - describe('before each hook error', function() { + describe('before each hook error', function () { before(run('hooks/beforeEach-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['before', bang + 'test 3'] @@ -36,9 +38,9 @@ describe('hook error handling', function() { }); }); - describe('after hook error', function() { + describe('after hook error', function () { before(run('hooks/after-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['test 1', 'test 2', 'after', bang + 'test 3'] @@ -46,9 +48,9 @@ describe('hook error handling', function() { }); }); - describe('after each hook error', function() { + describe('after each hook error', function () { before(run('hooks/afterEach-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['test 1', 'after', bang + 'test 3'] @@ -56,9 +58,9 @@ describe('hook error handling', function() { }); }); - describe('multiple hook errors', function() { + describe('multiple hook errors', function () { before(run('hooks/multiple-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, [ @@ -94,9 +96,9 @@ describe('hook error handling', function() { }); }); - describe('async - before hook error', function() { + describe('async - before hook error', function () { before(run('hooks/before-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['before', bang + 'test 3'] @@ -104,9 +106,9 @@ describe('hook error handling', function() { }); }); - describe('async - before hook error tip', function() { + describe('async - before hook error tip', function () { before(run('hooks/before-hook-async-error-tip.fixture.js', onlyErrorTitle)); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['1) spec 2 "before all" hook:'] @@ -114,9 +116,9 @@ describe('hook error handling', function() { }); }); - describe('async - before each hook error', function() { + describe('async - before each hook error', function () { before(run('hooks/beforeEach-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['before', bang + 'test 3'] @@ -124,9 +126,9 @@ describe('hook error handling', function() { }); }); - describe('async - after hook error', function() { + describe('async - after hook error', function () { before(run('hooks/after-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['test 1', 'test 2', 'after', bang + 'test 3'] @@ -134,9 +136,9 @@ describe('hook error handling', function() { }); }); - describe('async - after each hook error', function() { + describe('async - after each hook error', function () { before(run('hooks/afterEach-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, ['test 1', 'after', bang + 'test 3'] @@ -144,9 +146,9 @@ describe('hook error handling', function() { }); }); - describe('async - multiple hook errors', function() { + describe('async - multiple hook errors', function () { before(run('hooks/multiple-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { assert.deepEqual( lines, [ @@ -182,14 +184,14 @@ describe('hook error handling', function() { }); }); - function run(fnPath, outputFilter) { - return function(done) { - runMocha(fnPath, [], function(err, res) { + function run (fnPath, outputFilter) { + return function (done) { + runMocha(fnPath, [], function (err, res) { assert.ifError(err); lines = res.output .split(splitRegExp) - .map(function(line) { + .map(function (line) { return line.trim(); }) .filter(outputFilter || onlyConsoleOutput()); @@ -200,9 +202,9 @@ describe('hook error handling', function() { } }); -function onlyConsoleOutput() { +function onlyConsoleOutput () { var foundSummary = false; - return function(line) { + return function (line) { if (!foundSummary) { foundSummary = !!(/\(\d+ms\)/).exec(line); } @@ -210,6 +212,6 @@ function onlyConsoleOutput() { }; } -function onlyErrorTitle(line) { +function onlyErrorTitle (line) { return !!(/^1\)/).exec(line); } diff --git a/tests/lib/mocha-3.1.0/test/integration/hooks.spec.js b/tests/lib/mocha-3.1.2/test/integration/hooks.spec.js index 7633cb5630..0d31cbfdf4 100644 --- a/tests/lib/mocha-3.1.0/test/integration/hooks.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/hooks.spec.js @@ -1,18 +1,20 @@ +'use strict'; + var assert = require('assert'); -var run = require('./helpers').runMocha; +var run = require('./helpers').runMocha; var splitRegExp = require('./helpers').splitRegExp; -var args = []; +var args = []; -describe('hooks', function() { - it('are ran in correct order', function(done) { - run('cascade.fixture.js', args, function(err, res) { +describe('hooks', function () { + it('are ran in correct order', function (done) { + run('cascade.fixture.js', args, function (err, res) { var lines, expected; assert(!err); - lines = res.output.split(splitRegExp).map(function(line) { + lines = res.output.split(splitRegExp).map(function (line) { return line.trim(); - }).filter(function(line) { + }).filter(function (line) { return line.length; }).slice(0, -1); @@ -32,7 +34,7 @@ describe('hooks', function() { 'after one' ]; - expected.forEach(function(line, i) { + expected.forEach(function (line, i) { assert.equal(lines[i], line); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/multiple-done.spec.js b/tests/lib/mocha-3.1.2/test/integration/multiple-done.spec.js index 47e82dbebb..76a6483115 100644 --- a/tests/lib/mocha-3.1.0/test/integration/multiple-done.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/multiple-done.spec.js @@ -1,92 +1,94 @@ +'use strict'; + var assert = require('assert'); -var run = require('./helpers').runMochaJSON; -var args = []; +var run = require('./helpers').runMochaJSON; +var args = []; -describe('multiple calls to done()', function() { +describe('multiple calls to done()', function () { var res; - describe('from a spec', function() { - before(function(done) { - run('multiple-done.fixture.js', args, function(err, result) { + describe('from a spec', function () { + before(function (done) { + run('multiple-done.fixture.js', args, function (err, result) { res = result; done(err); }); }); - it('results in failures', function() { + it('results in failures', function () { assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 1); assert.equal(res.code, 1); }); - it('throws a descriptive error', function() { + it('throws a descriptive error', function () { assert.equal(res.failures[0].err.message, 'done() called multiple times'); }); }); - describe('with multiple specs', function() { - before(function(done) { - run('multiple-done-specs.fixture.js', args, function(err, result) { + describe('with multiple specs', function () { + before(function (done) { + run('multiple-done-specs.fixture.js', args, function (err, result) { res = result; done(err); }); }); - it('results in a failure', function() { + it('results in a failure', function () { assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); assert.equal(res.stats.failures, 1); assert.equal(res.code, 1); }); - it('correctly attributes the error', function() { + it('correctly attributes the error', function () { assert.equal(res.failures[0].fullTitle, 'suite test1'); assert.equal(res.failures[0].err.message, 'done() called multiple times'); }); }); - describe('from a before hook', function() { - before(function(done) { - run('multiple-done-before.fixture.js', args, function(err, result) { + describe('from a before hook', function () { + before(function (done) { + run('multiple-done-before.fixture.js', args, function (err, result) { res = result; done(err); }); }); - it('results in a failure', function() { + it('results in a failure', function () { assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 1); assert.equal(res.code, 1); }); - it('correctly attributes the error', function() { + it('correctly attributes the error', function () { assert.equal(res.failures[0].fullTitle, 'suite "before all" hook'); assert.equal(res.failures[0].err.message, 'done() called multiple times'); }); }); - describe('from a beforeEach hook', function() { - before(function(done) { - run('multiple-done-beforeEach.fixture.js', args, function(err, result) { + describe('from a beforeEach hook', function () { + before(function (done) { + run('multiple-done-beforeEach.fixture.js', args, function (err, result) { res = result; done(err); }); }); - it('results in a failure', function() { + it('results in a failure', function () { assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); assert.equal(res.stats.failures, 2); assert.equal(res.code, 2); }); - it('correctly attributes the errors', function() { + it('correctly attributes the errors', function () { assert.equal(res.failures.length, 2); - res.failures.forEach(function(failure) { + res.failures.forEach(function (failure) { assert.equal(failure.fullTitle, 'suite "before each" hook'); assert.equal(failure.err.message, 'done() called multiple times'); diff --git a/tests/lib/mocha-3.1.0/test/integration/only.spec.js b/tests/lib/mocha-3.1.2/test/integration/only.spec.js index 61254ce1d3..b37a4b263e 100644 --- a/tests/lib/mocha-3.1.0/test/integration/only.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/only.spec.js @@ -1,10 +1,12 @@ +'use strict'; + var run = require('./helpers').runMochaJSON; var assert = require('assert'); -describe('.only()', function() { - describe('bdd', function() { - it('should run only tests that marked as `only`', function(done) { - run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function(err, res) { +describe('.only()', function () { + describe('bdd', function () { + it('should run only tests that marked as `only`', function (done) { + run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 11); @@ -15,9 +17,9 @@ describe('.only()', function() { }); }); - describe('tdd', function() { - it('should run only tests that marked as `only`', function(done) { - run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function(err, res) { + describe('tdd', function () { + it('should run only tests that marked as `only`', function (done) { + run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 8); @@ -28,11 +30,9 @@ describe('.only()', function() { }); }); - describe('qunit', function() { - it('should run only tests that marked as `only`', function(done) { - run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function(err, res) { - console.log(err); - + describe('qunit', function () { + it('should run only tests that marked as `only`', function (done) { + run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 5); diff --git a/tests/lib/mocha-3.1.0/test/integration/options.spec.js b/tests/lib/mocha-3.1.2/test/integration/options.spec.js index 4755647f76..7c7a3cc75e 100644 --- a/tests/lib/mocha-3.1.0/test/integration/options.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/options.spec.js @@ -1,16 +1,17 @@ -var assert = require('assert'); -var run = require('./helpers').runMochaJSON; -var args = []; +'use strict'; -describe('options', function() { - describe('--async-only', function() { +var assert = require('assert'); +var run = require('./helpers').runMochaJSON; +var args = []; - before(function() { +describe('options', function () { + describe('--async-only', function () { + before(function () { args = ['--async-only']; }); - it('should fail synchronous specs', function(done) { - run('options/async-only-sync.fixture.js', args, function(err, res) { + it('should fail synchronous specs', function (done) { + run('options/async-only-sync.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); @@ -22,8 +23,8 @@ describe('options', function() { }); }); - it('should allow asynchronous specs', function(done) { - run('options/async-only-async.fixture.js', args, function(err, res) { + it('should allow asynchronous specs', function (done) { + run('options/async-only-async.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); @@ -36,13 +37,13 @@ describe('options', function() { }); }); - describe('--bail', function() { - before(function() { + describe('--bail', function () { + before(function () { args = ['--bail']; }); - it('should stop after the first error', function(done) { - run('options/bail.fixture.js', args, function(err, res) { + it('should stop after the first error', function (done) { + run('options/bail.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); @@ -56,13 +57,13 @@ describe('options', function() { }); }); - describe('--sort', function() { - before(function() { + describe('--sort', function () { + before(function () { args = ['--sort']; }); - it('should sort tests in alphabetical order', function(done) { - run('options/sort*', args, function(err, res) { + it('should sort tests in alphabetical order', function (done) { + run('options/sort*', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); @@ -76,13 +77,13 @@ describe('options', function() { }); }); - describe('--delay', function() { - before(function() { + describe('--delay', function () { + before(function () { args = ['--delay']; }); - it('should run the generated test suite', function(done) { - run('options/delay.fixture.js', args, function(err, res) { + it('should run the generated test suite', function (done) { + run('options/delay.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); @@ -95,8 +96,8 @@ describe('options', function() { }); }); - it('should throw an error if the test suite failed to run', function(done) { - run('options/delay-fail.fixture.js', args, function(err, res) { + it('should throw an error if the test suite failed to run', function (done) { + run('options/delay-fail.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); @@ -110,10 +111,10 @@ describe('options', function() { }); }); - describe('--grep', function() { - it('runs specs matching a string', function(done) { + describe('--grep', function () { + it('runs specs matching a string', function (done) { args = ['--grep', 'match']; - run('options/grep.fixture.js', args, function(err, res) { + run('options/grep.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); @@ -123,10 +124,10 @@ describe('options', function() { }); }); - describe('runs specs matching a RegExp', function() { - it('with RegExp like strings(pattern follow by flag)', function(done) { + describe('runs specs matching a RegExp', function () { + it('with RegExp like strings(pattern follow by flag)', function (done) { args = ['--grep', '/match/i']; - run('options/grep.fixture.js', args, function(err, res) { + run('options/grep.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 4); @@ -136,9 +137,9 @@ describe('options', function() { }); }); - it('string as pattern', function(done) { + it('string as pattern', function (done) { args = ['--grep', '.*']; - run('options/grep.fixture.js', args, function(err, res) { + run('options/grep.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 4); @@ -149,10 +150,10 @@ describe('options', function() { }); }); - describe('with --invert', function() { - it('runs specs that do not match the pattern', function(done) { + describe('with --invert', function () { + it('runs specs that do not match the pattern', function (done) { args = ['--grep', 'fail', '--invert']; - run('options/grep.fixture.js', args, function(err, res) { + run('options/grep.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 4); @@ -164,10 +165,10 @@ describe('options', function() { }); }); - describe('--retries', function() { + describe('--retries', function () { it('retries after a certain threshold', function (done) { args = ['--retries', '3']; - run('options/retries.fixture.js', args, function(err, res) { + run('options/retries.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); @@ -177,6 +178,6 @@ describe('options', function() { assert.equal(res.code, 1); done(); }); - }) + }); }); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/pending.spec.js b/tests/lib/mocha-3.1.2/test/integration/pending.spec.js index 4d4beffc2a..19ae30ad3a 100644 --- a/tests/lib/mocha-3.1.0/test/integration/pending.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/pending.spec.js @@ -1,11 +1,13 @@ +'use strict'; + var assert = require('assert'); -var run = require('./helpers').runMochaJSON; -var args = []; +var run = require('./helpers').runMochaJSON; +var args = []; -describe('pending', function() { - describe('pending specs', function() { - it('should be created by omitting a function', function(done) { - run('pending/spec.fixture.js', args, function(err, res) { +describe('pending', function () { + describe('pending specs', function () { + it('should be created by omitting a function', function (done) { + run('pending/spec.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 1); assert.equal(res.stats.passes, 0); @@ -16,10 +18,10 @@ describe('pending', function() { }); }); - describe('synchronous skip()', function() { - describe('in spec', function() { - it('should immediately skip the spec and run all others', function(done) { - run('pending/skip-sync-spec.fixture.js', args, function(err, res) { + describe('synchronous skip()', function () { + describe('in spec', function () { + it('should immediately skip the spec and run all others', function (done) { + run('pending/skip-sync-spec.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 1); assert.equal(res.stats.passes, 1); @@ -30,9 +32,9 @@ describe('pending', function() { }); }); - describe('in before', function() { - it('should skip all suite specs', function(done) { - run('pending/skip-sync-before.fixture.js', args, function(err, res) { + describe('in before', function () { + it('should skip all suite specs', function (done) { + run('pending/skip-sync-before.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); @@ -43,9 +45,9 @@ describe('pending', function() { }); }); - describe('in beforeEach', function() { - it('should skip all suite specs', function(done) { - run('pending/skip-sync-beforeEach.fixture.js', args, function(err, res) { + describe('in beforeEach', function () { + it('should skip all suite specs', function (done) { + run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); @@ -57,10 +59,10 @@ describe('pending', function() { }); }); - describe('asynchronous skip()', function() { - describe('in spec', function() { - it('should immediately skip the spec and run all others', function(done) { - run('pending/skip-async-spec.fixture.js', args, function(err, res) { + describe('asynchronous skip()', function () { + describe('in spec', function () { + it('should immediately skip the spec and run all others', function (done) { + run('pending/skip-async-spec.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 1); assert.equal(res.stats.passes, 1); @@ -71,9 +73,9 @@ describe('pending', function() { }); }); - describe('in before', function() { - it('should skip all suite specs', function(done) { - run('pending/skip-async-before.fixture.js', args, function(err, res) { + describe('in before', function () { + it('should skip all suite specs', function (done) { + run('pending/skip-async-before.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); @@ -84,9 +86,9 @@ describe('pending', function() { }); }); - describe('in beforeEach', function() { - it('should skip all suite specs', function(done) { - run('pending/skip-sync-beforeEach.fixture.js', args, function(err, res) { + describe('in beforeEach', function () { + it('should skip all suite specs', function (done) { + run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); diff --git a/tests/lib/mocha-3.1.0/test/integration/regression.spec.js b/tests/lib/mocha-3.1.2/test/integration/regression.spec.js index f2a435a34c..ffd17aa979 100644 --- a/tests/lib/mocha-3.1.0/test/integration/regression.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/regression.spec.js @@ -1,14 +1,16 @@ -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); -var run = require('./helpers').runMocha; +'use strict'; + +var assert = require('assert'); +var fs = require('fs'); +var path = require('path'); +var run = require('./helpers').runMocha; var runJSON = require('./helpers').runMochaJSON; -describe('regressions', function() { - it('issue-1327: should run all 3 specs exactly once', function(done) { +describe('regressions', function () { + it('issue-1327: should run all 3 specs exactly once', function (done) { var args = []; - run('regression/issue-1327.fixture.js', args, function(err, res) { - var occurences = function(str) { + run('regression/issue-1327.fixture.js', args, function (err, res) { + var occurences = function (str) { var pattern = new RegExp(str, 'g'); return (res.output.match(pattern) || []).length; }; @@ -23,32 +25,34 @@ describe('regressions', function() { }); }); - it('should not duplicate mocha.opts args in process.argv', function() { + it('should not duplicate mocha.opts args in process.argv', function () { var processArgv = process.argv.join(''); var mochaOpts = fs.readFileSync(path.join(__dirname, '..', 'mocha.opts'), 'utf-8').split(/[\s]+/).join(''); assert.notEqual(processArgv.indexOf(mochaOpts), -1, 'process.argv missing mocha.opts'); assert.equal(processArgv.indexOf(mochaOpts), processArgv.lastIndexOf(mochaOpts), 'process.argv contains duplicated mocha.opts'); }); - it('issue-1794: Can\'t --require custom UI and use it', function(done) { + it('issue-1794: Can\'t --require custom UI and use it', function (done) { var simpleUiPath = path.join(__dirname, 'fixtures', 'regression', '1794', 'simple-ui.js'); var args = ['--require', simpleUiPath, '--ui', 'simple-ui']; - run('regression/1794/issue-1794.fixture.js', args, function(err, res) { + run('regression/1794/issue-1794.fixture.js', args, function (err, res) { + assert(!err); assert.equal(res.code, 0, 'Custom UI should be loaded'); done(); }); }); - it('issue-1991: Declarations do not get cleaned up unless you set them to `null` - Memory Leak', function(done) { + it('issue-1991: Declarations do not get cleaned up unless you set them to `null` - Memory Leak', function (done) { // on a modern MBP takes ±5 seconds on node 4.0, but on older laptops with node 0.12 ±40 seconds. // Could easily take longer on even weaker machines (Travis-CI containers for example). this.timeout(120000); - run('regression/issue-1991.fixture.js', [], function(err, res) { + run('regression/issue-1991.fixture.js', [], function (err, res) { + assert(!err); assert.equal(/process out of memory/.test(res.output), false, 'fixture\'s process out of memory!'); assert.equal(res.code, 0, 'Runnable fn (it/before[Each]/after[Each]) references should be deleted to avoid memory leaks'); done(); }); - }) + }); describe('issue-2286: after doesn\'t execute if test was skipped in beforeEach', function () { var afterWasRun = false; @@ -56,14 +60,14 @@ describe('regressions', function() { beforeEach(function () { this.skip(); }); after(function () { afterWasRun = true; }); it('should be pending', function () {}); - }) + }); after('meta test', function () { afterWasRun.should.be.ok(); }); }); it('issue-2315: cannot read property currentRetry of undefined', function (done) { - runJSON('regression/issue-2315.js', [], function(err, res) { + runJSON('regression/issue-2315.js', [], function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); @@ -73,9 +77,9 @@ describe('regressions', function() { }); }); - it('issue-2406: should run nested describe.only suites', function(done) { + it('issue-2406: should run nested describe.only suites', function (done) { this.timeout(2000); - runJSON('regression/issue-2406.fixture.js', [], function(err, res) { + runJSON('regression/issue-2406.fixture.js', [], function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); @@ -85,8 +89,8 @@ describe('regressions', function() { }); }); - it('issue-2417: should not recurse infinitely with .only suites nested within each other', function() { - runJSON('regression/issue-2417.fixture.js', [], function(err, res) { + it('issue-2417: should not recurse infinitely with .only suites nested within each other', function () { + runJSON('regression/issue-2417.fixture.js', [], function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); @@ -94,4 +98,22 @@ describe('regressions', function() { assert.equal(res.code, 0); }); }); + + it('issue-1417 uncaught exceptions from async specs', function (done) { + runJSON('regression/issue-1417.js', [], function (err, res) { + assert(!err); + assert.equal(res.stats.pending, 0); + assert.equal(res.stats.passes, 0); + assert.equal(res.stats.failures, 2); + + assert.equal(res.failures[0].title, + 'fails exactly once when a global error is thrown synchronously and done errors'); + assert.equal(res.failures[0].err.message, 'sync error'); + assert.equal(res.failures[1].title, + 'fails exactly once when a global error is thrown synchronously and done completes'); + assert.equal(res.failures[1].err.message, 'sync error'); + assert.equal(res.code, 2); + done(); + }); + }); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/reporters.spec.js b/tests/lib/mocha-3.1.2/test/integration/reporters.spec.js index 9595611829..5cfee57037 100644 --- a/tests/lib/mocha-3.1.0/test/integration/reporters.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/reporters.spec.js @@ -1,26 +1,28 @@ +'use strict'; + var assert = require('assert'); -var os = require('os'); -var fs = require('fs'); +var os = require('os'); +var fs = require('fs'); var crypto = require('crypto'); -var path = require('path'); -var run = require('./helpers').runMocha; +var path = require('path'); +var run = require('./helpers').runMocha; -describe('reporters', function() { - describe('markdown', function() { +describe('reporters', function () { + describe('markdown', function () { var res; - before(function(done) { - run('passing.fixture.js', ['--reporter', 'markdown'], function(err, result) { + before(function (done) { + run('passing.fixture.js', ['--reporter', 'markdown'], function (err, result) { res = result; done(err); }); }); - it('does not exceed maximum callstack (issue: 1875)', function() { + it('does not exceed maximum callstack (issue: 1875)', function () { assert(res.output.indexOf('RangeError') === -1, 'Threw RangeError'); }); - it('contains spec src', function() { + it('contains spec src', function () { var src = [ '```js', 'assert(true);', @@ -31,8 +33,8 @@ describe('reporters', function() { }); }); - describe('xunit', function() { - it('prints test cases with --reporter-options output (issue: 1864)', function(done) { + describe('xunit', function () { + it('prints test cases with --reporter-options output (issue: 1864)', function (done) { var randomStr = crypto.randomBytes(8).toString('hex'); var tmpDir = os.tmpDir().replace(new RegExp(path.sep + '$'), ''); var tmpFile = tmpDir + path.sep + 'test-issue-1864-' + randomStr + '.xml'; @@ -44,13 +46,13 @@ describe('reporters', function() { '</testsuite>' ]; - run('passing.fixture.js', args, function(err, result) { + run('passing.fixture.js', args, function (err, result) { if (err) return done(err); var xml = fs.readFileSync(tmpFile, 'utf8'); fs.unlinkSync(tmpFile); - expectedOutput.forEach(function(line) { + expectedOutput.forEach(function (line) { assert(xml.indexOf(line) !== -1, 'XML did not contain ' + line); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/retries.spec.js b/tests/lib/mocha-3.1.2/test/integration/retries.spec.js index ce76545b00..28ed702c5f 100644 --- a/tests/lib/mocha-3.1.0/test/integration/retries.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/retries.spec.js @@ -1,18 +1,20 @@ +'use strict'; + var assert = require('assert'); var helpers = require('./helpers'); -var args = []; +var args = []; var bang = require('../../lib/reporters/base').symbols.bang; -describe('retries', function() { - it('are ran in correct order', function(done) { - helpers.runMocha('retries/hooks.fixture.js', args, function(err, res) { +describe('retries', function () { + it('are ran in correct order', function (done) { + helpers.runMocha('retries/hooks.fixture.js', args, function (err, res) { var lines, expected; assert(!err); - lines = res.output.split(helpers.splitRegExp).map(function(line) { + lines = res.output.split(helpers.splitRegExp).map(function (line) { return line.trim(); - }).filter(function(line) { + }).filter(function (line) { return line.length; }).slice(0, -1); @@ -36,7 +38,7 @@ describe('retries', function() { 'after' ]; - expected.forEach(function(line, i) { + expected.forEach(function (line, i) { assert.equal(lines[i], line); }); @@ -46,7 +48,7 @@ describe('retries', function() { }); it('should exit early if test passes', function (done) { - helpers.runMochaJSON('retries/early-pass.fixture.js', args, function(err, res) { + helpers.runMochaJSON('retries/early-pass.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); @@ -58,7 +60,7 @@ describe('retries', function() { }); it('should let test override', function (done) { - helpers.runMochaJSON('retries/nested.fixture.js', args, function(err, res) { + helpers.runMochaJSON('retries/nested.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 1); @@ -70,14 +72,14 @@ describe('retries', function() { }); it('should not hang w/ async test', function (done) { - helpers.runMocha('retries/async.fixture.js', args, function(err, res) { + helpers.runMocha('retries/async.fixture.js', args, function (err, res) { var lines, expected; assert(!err); - lines = res.output.split(helpers.splitRegExp).map(function(line) { + lines = res.output.split(helpers.splitRegExp).map(function (line) { return line.trim(); - }).filter(function(line) { + }).filter(function (line) { return line.length; }).slice(0, -1); @@ -95,7 +97,7 @@ describe('retries', function() { 'after' ]; - expected.forEach(function(line, i) { + expected.forEach(function (line, i) { assert.equal(lines[i], line); }); diff --git a/tests/lib/mocha-3.1.0/test/integration/suite.spec.js b/tests/lib/mocha-3.1.2/test/integration/suite.spec.js index 00066a34f4..171a929ed1 100644 --- a/tests/lib/mocha-3.1.0/test/integration/suite.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/suite.spec.js @@ -1,11 +1,13 @@ +'use strict'; + var assert = require('assert'); var run = require('./helpers').runMocha; var args = []; -describe('suite w/no callback', function() { +describe('suite w/no callback', function () { this.timeout(1000); - it('should throw a helpful error message when a callback for suite is not supplied', function(done) { - run('suite/suite-no-callback.fixture.js', args, function(err, res) { + it('should throw a helpful error message when a callback for suite is not supplied', function (done) { + run('suite/suite-no-callback.fixture.js', args, function (err, res) { assert(!err); var result = res.output.match(/no callback was supplied/) || []; assert.equal(result.length, 1); @@ -14,12 +16,12 @@ describe('suite w/no callback', function() { }); }); -describe('skipped suite w/no callback', function() { +describe('skipped suite w/no callback', function () { this.timeout(1000); - it('should not throw an error when a callback for skipped suite is not supplied', function(done) { - run('suite/suite-skipped-no-callback.fixture.js', args, function(err, res) { + it('should not throw an error when a callback for skipped suite is not supplied', function (done) { + run('suite/suite-skipped-no-callback.fixture.js', args, function (err, res) { assert(!err); - pattern = new RegExp("Error", 'g'); + var pattern = new RegExp('Error', 'g'); var result = res.output.match(pattern) || []; assert.equal(result.length, 0); done(); @@ -27,13 +29,12 @@ describe('skipped suite w/no callback', function() { }); }); - -describe('skipped suite w/ callback', function() { +describe('skipped suite w/ callback', function () { this.timeout(1000); - it('should not throw an error when a callback for skipped suite is supplied', function(done) { - run('suite/suite-skipped-callback.fixture.js', args, function(err, res) { + it('should not throw an error when a callback for skipped suite is supplied', function (done) { + run('suite/suite-skipped-callback.fixture.js', args, function (err, res) { assert(!err); - pattern = new RegExp("Error", 'g'); + var pattern = new RegExp('Error', 'g'); var result = res.output.match(pattern) || []; assert.equal(result.length, 0); done(); diff --git a/tests/lib/mocha-3.1.0/test/integration/timeout.spec.js b/tests/lib/mocha-3.1.2/test/integration/timeout.spec.js index 33b8e33093..4e0f989e86 100644 --- a/tests/lib/mocha-3.1.0/test/integration/timeout.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/timeout.spec.js @@ -1,10 +1,12 @@ +'use strict'; + var assert = require('assert'); -var run = require('./helpers').runMochaJSON; -var args = []; +var run = require('./helpers').runMochaJSON; +var args = []; -describe('this.timeout()', function() { - it('is respected by sync and async suites', function(done) { - run('timeout.fixture.js', args, function(err, res) { +describe('this.timeout()', function () { + it('is respected by sync and async suites', function (done) { + run('timeout.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); diff --git a/tests/lib/mocha-3.1.0/test/integration/uncaught.spec.js b/tests/lib/mocha-3.1.2/test/integration/uncaught.spec.js index 87dde90902..92e39c195e 100644 --- a/tests/lib/mocha-3.1.0/test/integration/uncaught.spec.js +++ b/tests/lib/mocha-3.1.2/test/integration/uncaught.spec.js @@ -1,10 +1,12 @@ +'use strict'; + var assert = require('assert'); -var run = require('./helpers').runMochaJSON; -var args = []; +var run = require('./helpers').runMochaJSON; +var args = []; -describe('uncaught exceptions', function() { - it('handles uncaught exceptions from hooks', function(done) { - run('uncaught-hook.fixture.js', args, function(err, res) { +describe('uncaught exceptions', function () { + it('handles uncaught exceptions from hooks', function (done) { + run('uncaught-hook.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); @@ -17,8 +19,8 @@ describe('uncaught exceptions', function() { }); }); - it('handles uncaught exceptions from async specs', function(done) { - run('uncaught.fixture.js', args, function(err, res) { + it('handles uncaught exceptions from async specs', function (done) { + run('uncaught.fixture.js', args, function (err, res) { assert(!err); assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); diff --git a/tests/lib/mocha-3.1.0/test/jsapi/index.js b/tests/lib/mocha-3.1.2/test/jsapi/index.js index a096186b96..42133578e0 100644 --- a/tests/lib/mocha-3.1.0/test/jsapi/index.js +++ b/tests/lib/mocha-3.1.2/test/jsapi/index.js @@ -1,5 +1,6 @@ -var Mocha = require('../../') - , path = require('path'); +'use strict'; + +var Mocha = require('../../'); var mocha = new Mocha({ ui: 'bdd', @@ -22,8 +23,8 @@ mocha.addFile('test/acceptance/fs.spec.js'); mocha.addFile('test/acceptance/globals.spec.js'); mocha.addFile('test/acceptance/timeout.spec.js'); -mocha.run(function(){ +mocha.run(function () { console.log('done'); -}).on('pass', function(test){ +}).on('pass', function (test) { // console.log('... %s', test.title); }); diff --git a/tests/lib/mocha-3.1.0/test/mocha.opts b/tests/lib/mocha-3.1.2/test/mocha.opts index cd797e2ae0..36146eb65e 100644 --- a/tests/lib/mocha-3.1.0/test/mocha.opts +++ b/tests/lib/mocha-3.1.2/test/mocha.opts @@ -1,5 +1,5 @@ --require should ---require ./test/fixture-expect.js +--require ./test/setup --reporter dot --ui bdd --globals okGlobalA,okGlobalB diff --git a/tests/lib/mocha-3.1.0/test/mocha.spec.js b/tests/lib/mocha-3.1.2/test/mocha.spec.js index 46411fc18b..618742cdbd 100644 --- a/tests/lib/mocha-3.1.0/test/mocha.spec.js +++ b/tests/lib/mocha-3.1.2/test/mocha.spec.js @@ -1,33 +1,35 @@ +'use strict'; + var Mocha = require('../'); var Test = Mocha.Test; -describe('Mocha', function(){ - var blankOpts = { reporter: function(){} }; // no output +describe('Mocha', function () { + var blankOpts = { reporter: function () {} }; // no output - describe('.run(fn)', function(){ - it('should not raise errors if callback was not provided', function(){ + describe('.run(fn)', function () { + it('should not raise errors if callback was not provided', function () { var mocha = new Mocha(blankOpts); mocha.run(); - }) + }); - it('should execute the callback when complete', function(done) { + it('should execute the callback when complete', function (done) { var mocha = new Mocha(blankOpts); - mocha.run(function(){ + mocha.run(function () { done(); - }) - }) + }); + }); - it('should execute the callback with the number of failures '+ - 'as parameter', function(done) { + it('should execute the callback with the number of failures ' + + 'as parameter', function (done) { var mocha = new Mocha(blankOpts); - var failingTest = new Test('failing test', function(){ + var failingTest = new Test('failing test', function () { throw new Error('such fail'); }); mocha.suite.addTest(failingTest); - mocha.run(function(failures) { + mocha.run(function (failures) { failures.should.equal(1); done(); }); - }) - }) -}) + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/ms.spec.js b/tests/lib/mocha-3.1.2/test/ms.spec.js index 1fd9740a62..26f5c30209 100644 --- a/tests/lib/mocha-3.1.0/test/ms.spec.js +++ b/tests/lib/mocha-3.1.2/test/ms.spec.js @@ -1,71 +1,71 @@ 'use strict'; var ms = require('../lib/ms'); -describe('.ms()', function() { +describe('.ms()', function () { // Helpers var time = { - minutes: function(n) { return n * 60 * 1000; }, + minutes: function (n) { return n * 60 * 1000; }, hours: function (n) { return n * this.minutes(60); }, - days: function(n) { return n * this.hours(24); }, - years: function(n) { return n * this.days(365.25); } + days: function (n) { return n * this.hours(24); }, + years: function (n) { return n * this.days(365.25); } }; - describe('get a value that less than 1 second', function() { - it('should return milliseconds representation', function() { + describe('get a value that less than 1 second', function () { + it('should return milliseconds representation', function () { ms(200).should.equal('200ms'); ms(30).should.equal('30ms'); ms(2000).should.not.equal('2000ms'); }); }); - describe('seconds representation', function() { - it('should return short format', function() { + describe('seconds representation', function () { + it('should return short format', function () { ms(2000).should.equal('2s'); }); - it('should return long format', function() { + it('should return long format', function () { ms(2000, { long: true }).should.equal('2 seconds'); ms(1000, { long: true }).should.equal('1 second'); ms(1010, { long: true }).should.equal('1 second'); }); }); - describe('minutess representation', function() { - it('should return short format', function() { + describe('minutess representation', function () { + it('should return short format', function () { ms(time.minutes(1)).should.equal('1m'); }); - it('should return long format', function() { + it('should return long format', function () { ms(time.minutes(1), { long: true }).should.equal('1 minute'); ms(time.minutes(3), { long: true }).should.equal('3 minutes'); }); }); - describe('hours representation', function() { - it('should return short format', function() { + describe('hours representation', function () { + it('should return short format', function () { ms(time.hours(1)).should.equal('1h'); }); - it('should return long format', function() { + it('should return long format', function () { ms(time.hours(1), { long: true }).should.equal('1 hour'); ms(time.hours(3), { long: true }).should.equal('3 hours'); }); }); - describe('days representation', function() { - it('should return short format', function() { + describe('days representation', function () { + it('should return short format', function () { ms(time.days(1)).should.equal('1d'); }); - it('should return long format', function() { + it('should return long format', function () { ms(time.days(1), { long: true }).should.equal('1 day'); ms(time.days(3), { long: true }).should.equal('3 days'); }); }); - describe('Getting string value', function() { - it('should return the milliseconds representation(Number)', function() { + describe('Getting string value', function () { + it('should return the milliseconds representation(Number)', function () { ms('1 second').should.equal(1000); - + ms('1 minute').should.equal(time.minutes(1)); ms('6 minutes').should.equal(time.minutes(6)); diff --git a/tests/lib/mocha-3.1.0/test/reporters/base.spec.js b/tests/lib/mocha-3.1.2/test/reporters/base.spec.js index bbd0d3a9a7..6282d882ff 100644 --- a/tests/lib/mocha-3.1.0/test/reporters/base.spec.js +++ b/tests/lib/mocha-3.1.2/test/reporters/base.spec.js @@ -1,9 +1,11 @@ +'use strict'; + var assert = require('assert'); -var Base = require('../../lib/reporters/base') - , Assert = require('assert').AssertionError; +var Base = require('../../lib/reporters/base'); +var Assert = require('assert').AssertionError; -function makeTest(err) { +function makeTest (err) { return { err: err, fullTitle: function () { @@ -13,9 +15,9 @@ function makeTest(err) { } describe('Base reporter', function () { - var stdout - , stdoutWrite - , useColors; + var stdout; + var stdoutWrite; + var useColors; beforeEach(function () { stdout = []; @@ -32,10 +34,10 @@ describe('Base reporter', function () { Base.useColors = useColors; }); - describe('showDiff', function() { + describe('showDiff', function () { it('should show diffs by default', function () { - var err = new Assert({ actual: 'foo', expected: 'bar' }) - , errOut; + var err = new Assert({ actual: 'foo', expected: 'bar' }); + var errOut; var test = makeTest(err); @@ -47,13 +49,12 @@ describe('Base reporter', function () { }); it('should show diffs if property set to `true`', function () { - var err = new Assert({ actual: 'foo', expected: 'bar' }) - , errOut; + var err = new Assert({ actual: 'foo', expected: 'bar' }); + var errOut; err.showDiff = true; var test = makeTest(err); - Base.list([test]); errOut = stdout.join('\n'); @@ -62,8 +63,8 @@ describe('Base reporter', function () { }); it('should not show diffs when showDiff property set to `false`', function () { - var err = new Assert({ actual: 'foo', expected: 'bar' }) - , errOut; + var err = new Assert({ actual: 'foo', expected: 'bar' }); + var errOut; err.showDiff = false; var test = makeTest(err); @@ -76,8 +77,8 @@ describe('Base reporter', function () { }); it('should not show diffs when expected is not defined', function () { - var err = new Error('ouch') - , errOut; + var err = new Error('ouch'); + var errOut; var test = makeTest(err); @@ -87,14 +88,13 @@ describe('Base reporter', function () { errOut.should.not.match(/\- actual/); errOut.should.not.match(/\+ expected/); }); - }); - describe('Getting two strings', function() { + describe('Getting two strings', function () { // Fix regression V1.2.1(see: issue #1241) it('should show strings diff as is', function () { - var err = new Error('test'), - errOut; + var err = new Error('test'); + var errOut; err.actual = 'foo\nbar'; err.expected = 'foo\nbaz'; @@ -114,11 +114,11 @@ describe('Base reporter', function () { }); it('should stringify objects', function () { - var err = new Error('test'), - errOut; + var err = new Error('test'); + var errOut; - err.actual = {key:"a1"}; - err.expected = {key:"e1"}; + err.actual = {key: 'a1'}; + err.expected = {key: 'e1'}; err.showDiff = true; var test = makeTest(err); @@ -132,8 +132,8 @@ describe('Base reporter', function () { }); it('should stringify Object.create(null)', function () { - var err = new Error('test'), - errOut; + var err = new Error('test'); + var errOut; err.actual = Object.create(null); err.actual.hasOwnProperty = 1; @@ -189,7 +189,7 @@ describe('Base reporter', function () { it('should use the inspect() property if `message` is not set', function () { var err = { showDiff: false, - inspect: function() { return 'an error happened'; }, + inspect: function () { return 'an error happened'; } }; var test = makeTest(err); Base.list([test]); @@ -210,5 +210,4 @@ describe('Base reporter', function () { var errOut = stdout.join('\n').trim(); errOut.should.equal('1) test title:\n Error\n foo\n bar'); }); - }); diff --git a/tests/lib/mocha-3.1.2/test/reporters/json.spec.js b/tests/lib/mocha-3.1.2/test/reporters/json.spec.js new file mode 100644 index 0000000000..74151fdc8b --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/reporters/json.spec.js @@ -0,0 +1,63 @@ +'use strict'; + +var Mocha = require('../../'); +var Suite = Mocha.Suite; +var Runner = Mocha.Runner; +var Test = Mocha.Test; + +describe('json reporter', function () { + var suite, runner; + + beforeEach(function () { + var mocha = new Mocha({ + reporter: 'json' + }); + suite = new Suite('JSON suite', 'root'); + runner = new Runner(suite); + /* eslint no-unused-vars: off */ + var mochaReporter = new mocha._reporter(runner); + }); + + it('should have 1 test failure', function (done) { + var testTitle = 'json test 1'; + var error = { message: 'oh shit' }; + + suite.addTest(new Test(testTitle, function (done) { + done(new Error(error.message)); + })); + + runner.run(function (failureCount) { + failureCount.should.be.exactly(1); + runner.should.have.property('testResults'); + runner.testResults.should.have.property('failures'); + runner.testResults.failures.should.be.an.instanceOf(Array); + runner.testResults.failures.should.have.a.lengthOf(1); + + var failure = runner.testResults.failures[0]; + failure.should.have.property('title', testTitle); + failure.err.message.should.equal(error.message); + failure.should.have.properties('err'); + + done(); + }); + }); + + it('should have 1 test pending', function (done) { + var testTitle = 'json test 1'; + + suite.addTest(new Test(testTitle)); + + runner.run(function (failureCount) { + failureCount.should.be.exactly(0); + runner.should.have.property('testResults'); + runner.testResults.should.have.property('pending'); + runner.testResults.pending.should.be.an.instanceOf(Array); + runner.testResults.pending.should.have.a.lengthOf(1); + + var pending = runner.testResults.pending[0]; + pending.should.have.property('title', testTitle); + + done(); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/reporters/nyan.spec.js b/tests/lib/mocha-3.1.2/test/reporters/nyan.spec.js index 37c9b7c372..07c455efd3 100644 --- a/tests/lib/mocha-3.1.0/test/reporters/nyan.spec.js +++ b/tests/lib/mocha-3.1.2/test/reporters/nyan.spec.js @@ -1,30 +1,31 @@ -var reporters = require('../../').reporters - , NyanCat = reporters.Nyan; +'use strict'; +var reporters = require('../../').reporters; +var NyanCat = reporters.Nyan; describe('nyan face', function () { it('nyan face:(x .x) when "failures" at least one', function () { - var nyanCat = new NyanCat({on: function(){}}); + var nyanCat = new NyanCat({on: function () {}}); nyanCat.stats = { passes: 2, pending: 1, failures: 1 }; - nyanCat.face.call(nyanCat).should.equal('( x .x)'); + nyanCat.face().should.equal('( x .x)'); }); it('expected nyan face:(x .x) when "pending" at least one and no failing', function () { - var nyanCat = new NyanCat({on: function(){}}); + var nyanCat = new NyanCat({on: function () {}}); nyanCat.stats = { passes: 2, pending: 1, failures: 0 }; - nyanCat.face.call(nyanCat).should.equal('( o .o)'); + nyanCat.face().should.equal('( o .o)'); }); it('expected nyan face:(^ .^) when "passing" only', function () { - var nyanCat = new NyanCat({on: function(){}}); + var nyanCat = new NyanCat({on: function () {}}); nyanCat.stats = { passes: 1, pending: 0, failures: 0 }; - nyanCat.face.call(nyanCat).should.equal('( ^ .^)'); + nyanCat.face().should.equal('( ^ .^)'); }); it('nyan face:(- .-) when otherwise', function (done) { - var nyanCat = new NyanCat({on: function(){}}); + var nyanCat = new NyanCat({on: function () {}}); nyanCat.stats = { passes: 0, pending: 0, failures: 0 }; - nyanCat.face.call(nyanCat).should.equal('( - .-)'); + nyanCat.face().should.equal('( - .-)'); done(); }); }); diff --git a/tests/lib/mocha-3.1.0/test/runnable.spec.js b/tests/lib/mocha-3.1.2/test/runnable.spec.js index d6b020a6a1..67cfcca38a 100644 --- a/tests/lib/mocha-3.1.0/test/runnable.spec.js +++ b/tests/lib/mocha-3.1.2/test/runnable.spec.js @@ -1,187 +1,188 @@ -var mocha = require('../') - , utils = mocha.utils - , Runnable = mocha.Runnable - , EventEmitter = require('events').EventEmitter; +'use strict'; -describe('Runnable(title, fn)', function(){ +var mocha = require('../'); +var utils = mocha.utils; +var Runnable = mocha.Runnable; + +describe('Runnable(title, fn)', function () { // For every test we poison the global time-related methods. // runnable.js etc. should keep its own local copy, in order to fix GH-237. // NB: we can't poison global.Date because the normal implementation of // global.setTimeout uses it [1] so if the runnable.js keeps a copy of // global.setTimeout (like it's supposed to), that will blow up. // [1]: https://github.com/joyent/node/blob/7fc835afe362ebd30a0dbec81d3360bd24525222/lib/timers.js#L74 - var setTimeout = global.setTimeout - , setInterval = global.setInterval - , clearTimeout = global.clearTimeout - , clearInterval = global.clearInterval; + var setTimeout = global.setTimeout; + var setInterval = global.setInterval; + var clearTimeout = global.clearTimeout; + var clearInterval = global.clearInterval; - function poisonPill() { + function poisonPill () { throw new Error("Don't use global time-related stuff."); } - beforeEach(function(){ + beforeEach(function () { global.setTimeout = global.setInterval = global.clearTimeout = global.clearInterval = poisonPill; - }) + }); - afterEach(function(){ + afterEach(function () { global.setTimeout = setTimeout; global.setInterval = setInterval; global.clearTimeout = clearTimeout; global.clearInterval = clearInterval; - }) + }); - describe('#timeout(ms)', function(){ - it('should set the timeout', function(){ - var run = new Runnable; - run.timeout(1000) + describe('#timeout(ms)', function () { + it('should set the timeout', function () { + var run = new Runnable(); + run.timeout(1000); run.timeout().should.equal(1000); - }) - }) + }); + }); - describe('#timeout(ms) when ms>2^31', function() { - it('should set disabled', function() { + describe('#timeout(ms) when ms>2^31', function () { + it('should set disabled', function () { var run = new Runnable(); run.timeout(1e10); run.enableTimeouts().should.be.false; }); }); - describe('#enableTimeouts(enabled)', function(){ - it('should set enabled', function(){ - var run = new Runnable; + describe('#enableTimeouts(enabled)', function () { + it('should set enabled', function () { + var run = new Runnable(); run.enableTimeouts(false); run.enableTimeouts().should.equal(false); }); }); - describe('#slow(ms)', function() { + describe('#slow(ms)', function () { var run; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); }); - it('should set the slow threshold', function() { + it('should set the slow threshold', function () { run.slow(100); run.slow().should.equal(100); }); - it('should not set the slow threshold if the parameter is not passed', function() { + it('should not set the slow threshold if the parameter is not passed', function () { run.slow(); run.slow().should.equal(75); }); - it('should not set the slow threshold if the parameter is undefined', function() { + it('should not set the slow threshold if the parameter is undefined', function () { run.slow(undefined); run.slow().should.equal(75); }); - }) + }); - describe('.title', function(){ - it('should be present', function(){ + describe('.title', function () { + it('should be present', function () { new Runnable('foo').title.should.equal('foo'); - }) - }) + }); + }); - describe('when arity >= 1', function(){ - it('should be .async', function(){ - var run = new Runnable('foo', function(done){}); + describe('when arity >= 1', function () { + it('should be .async', function () { + var run = new Runnable('foo', function (done) {}); run.async.should.equal(1); run.sync.should.be.false(); - }) - }) + }); + }); - describe('when arity == 0', function(){ - it('should be .sync', function(){ - var run = new Runnable('foo', function(){}); + describe('when arity == 0', function () { + it('should be .sync', function () { + var run = new Runnable('foo', function () {}); run.async.should.be.equal(0); run.sync.should.be.true(); - }) - }) + }); + }); - describe('#globals', function(){ - it('should allow for whitelisting globals', function(done){ - var test = new Runnable('foo', function(){}); + describe('#globals', function () { + it('should allow for whitelisting globals', function (done) { + var test = new Runnable('foo', function () {}); test.async.should.be.equal(0); test.sync.should.be.true(); test.globals(['foobar']); test.run(done); - }) - }) + }); + }); - describe('#retries(n)', function(){ - it('should set the number of retries', function(){ - var run = new Runnable; + describe('#retries(n)', function () { + it('should set the number of retries', function () { + var run = new Runnable(); run.retries(1); run.retries().should.equal(1); - }) - }) + }); + }); - describe('.run(fn)', function(){ - describe('when .pending', function(){ - it('should not invoke the callback', function(done){ - var test = new Runnable('foo', function(){ + describe('.run(fn)', function () { + describe('when .pending', function () { + it('should not invoke the callback', function (done) { + var test = new Runnable('foo', function () { throw new Error('should not be called'); }); test.pending = true; test.run(done); - }) - }) + }); + }); - describe('when sync', function(){ - describe('without error', function(){ - it('should invoke the callback', function(done){ + describe('when sync', function () { + describe('without error', function () { + it('should invoke the callback', function (done) { var calls = 0; - var test = new Runnable('foo', function(){ + var test = new Runnable('foo', function () { ++calls; }); - test.run(function(err){ + test.run(function (err) { calls.should.equal(1); test.duration.should.be.type('number'); done(err); - }) - }) - }) + }); + }); + }); - describe('when an exception is thrown', function(){ - it('should invoke the callback', function(done){ + describe('when an exception is thrown', function () { + it('should invoke the callback', function (done) { var calls = 0; - var test = new Runnable('foo', function(){ + var test = new Runnable('foo', function () { ++calls; throw new Error('fail'); }); - test.run(function(err){ + test.run(function (err) { calls.should.equal(1); err.message.should.equal('fail'); done(); - }) - }) - }) + }); + }); + }); - describe('when an exception is thrown and is allowed to remain uncaught', function(){ - it('throws an error when it is allowed', function(done) { - var test = new Runnable('foo', function(){ + describe('when an exception is thrown and is allowed to remain uncaught', function () { + it('throws an error when it is allowed', function (done) { + var test = new Runnable('foo', function () { throw new Error('fail'); }); test.allowUncaught = true; - function fail() { - test.run(function(err) {}); + function fail () { + test.run(function () {}); } fail.should.throw('fail'); done(); - }) - }) - }) + }); + }); + }); - describe('when timeouts are disabled', function() { - it('should not error with timeout', function(done) { - var test = new Runnable('foo', function(done){ + 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); }); test.timeout(1); @@ -190,32 +191,31 @@ describe('Runnable(title, fn)', function(){ }); }); - describe('when async', function(){ - describe('without error', function(){ - it('should invoke the callback', function(done){ - var calls = 0; - var test = new Runnable('foo', function(done){ + describe('when async', function () { + describe('without error', function () { + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function (done) { process.nextTick(done); }); test.run(done); - }) - }) + }); + }); - describe('when the callback is invoked several times', function(){ - describe('without an error', function(){ - it('should emit a single "error" event', function(done){ + describe('when the callback is invoked several times', function () { + describe('without an error', function () { + it('should emit a single "error" event', function (done) { var calls = 0; var errCalls = 0; - var test = new Runnable('foo', function(done){ + var test = new Runnable('foo', function (done) { process.nextTick(done); process.nextTick(done); process.nextTick(done); process.nextTick(done); }); - test.on('error', function(err){ + test.on('error', function (err) { ++errCalls; err.message.should.equal('done() called multiple times'); calls.should.equal(1); @@ -223,18 +223,18 @@ describe('Runnable(title, fn)', function(){ done(); }); - test.run(function(){ + test.run(function () { ++calls; }); - }) - }) + }); + }); - describe('with an error', function(){ - it('should emit a single "error" event', function(done){ + describe('with an error', function () { + it('should emit a single "error" event', function (done) { var calls = 0; var errCalls = 0; - var test = new Runnable('foo', function(done){ + var test = new Runnable('foo', function (done) { done(new Error('fail')); process.nextTick(done); done(new Error('fail')); @@ -242,7 +242,7 @@ describe('Runnable(title, fn)', function(){ process.nextTick(done); }); - test.on('error', function(err){ + test.on('error', function (err) { ++errCalls; err.message.should.equal('fail'); calls.should.equal(1); @@ -250,133 +250,129 @@ describe('Runnable(title, fn)', function(){ done(); }); - test.run(function(){ + test.run(function () { ++calls; }); - }) - }) - }) + }); + }); + }); - describe('when an exception is thrown', function(){ - it('should invoke the callback', function(done){ - var calls = 0; - var test = new Runnable('foo', function(done){ + describe('when an exception is thrown', function () { + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function (done) { throw new Error('fail'); - process.nextTick(done); }); - test.run(function(err){ + test.run(function (err) { err.message.should.equal('fail'); done(); }); - }) + }); it('should not throw its own exception if passed a non-object', function (done) { - var test = new Runnable('foo', function(done) { + var test = new Runnable('foo', function (done) { + /* eslint no-throw-literal: off */ throw null; - process.nextTick(done); }); - test.run(function(err) { + test.run(function (err) { err.message.should.equal(utils.undefinedError().message); done(); - }) + }); }); - }) + }); - describe('when an exception is thrown and is allowed to remain uncaught', function(){ - it('throws an error when it is allowed', function(done) { - var test = new Runnable('foo', function(done){ + describe('when an exception is thrown and is allowed to remain uncaught', function () { + it('throws an error when it is allowed', function (done) { + var test = new Runnable('foo', function (done) { throw new Error('fail'); - process.nextTick(done); }); test.allowUncaught = true; - function fail() { - test.run(function(err) {}); + function fail () { + test.run(function () {}); } fail.should.throw('fail'); done(); - }) - }) + }); + }); - describe('when an error is passed', function(){ - it('should invoke the callback', function(done){ - var calls = 0; - var test = new Runnable('foo', function(done){ + describe('when an error is passed', function () { + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function (done) { done(new Error('fail')); }); - test.run(function(err){ + test.run(function (err) { err.message.should.equal('fail'); done(); }); - }) - }) + }); + }); - describe('when done() is invoked with a non-Error object', function(){ - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(done){ + describe('when done() is invoked with a non-Error object', function () { + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function (done) { done({ error: 'Test error' }); }); - test.run(function(err){ + test.run(function (err) { err.message.should.equal('done() invoked with non-Error: {"error":"Test error"}'); done(); }); - }) - }) + }); + }); - describe('when done() is invoked with a string', function(){ - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(done){ + describe('when done() is invoked with a string', function () { + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function (done) { done('Test error'); }); - test.run(function(err){ + test.run(function (err) { err.message.should.equal('done() invoked with non-Error: Test error'); done(); }); - }) - }) + }); + }); - it('should allow updating the timeout', function(done){ + it('should allow updating the timeout', function (done) { var callCount = 0; - var increment = function() { + var increment = function () { callCount++; }; - var test = new Runnable('foo', function(done){ + var test = new Runnable('foo', function (done) { setTimeout(increment, 1); setTimeout(increment, 100); }); test.timeout(10); - test.run(function(err){ + test.run(function (err) { err.should.be.ok(); callCount.should.equal(1); done(); }); - }) + }); - it('should allow a timeout of 0') - }) + it('should allow a timeout of 0'); + }); - describe('when fn returns a promise', function(){ - describe('when the promise is fulfilled with no value', function(){ + describe('when fn returns a promise', function () { + describe('when the promise is fulfilled with no value', function () { var fulfilledPromise = { then: function (fulfilled, rejected) { process.nextTick(fulfilled); } }; - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(){ + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function () { return fulfilledPromise; }); test.run(done); - }) - }) + }); + }); - describe('when the promise is fulfilled with a value', function(){ + describe('when the promise is fulfilled with a value', function () { var fulfilledPromise = { then: function (fulfilled, rejected) { process.nextTick(function () { @@ -385,16 +381,16 @@ describe('Runnable(title, fn)', function(){ } }; - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(){ + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function () { return fulfilledPromise; }); test.run(done); - }) - }) + }); + }); - describe('when the promise is rejected', function(){ + describe('when the promise is rejected', function () { var expectedErr = new Error('fail'); var rejectedPromise = { then: function (fulfilled, rejected) { @@ -404,19 +400,19 @@ describe('Runnable(title, fn)', function(){ } }; - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(){ + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function () { return rejectedPromise; }); - test.run(function(err){ + test.run(function (err) { err.should.equal(expectedErr); done(); }); - }) - }) + }); + }); - describe('when the promise is rejected without a reason', function(){ + describe('when the promise is rejected without a reason', function () { var expectedErr = new Error('Promise rejected with no or falsy reason'); var rejectedPromise = { then: function (fulfilled, rejected) { @@ -426,45 +422,45 @@ describe('Runnable(title, fn)', function(){ } }; - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(){ + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function () { return rejectedPromise; }); - test.run(function(err){ + test.run(function (err) { err.should.eql(expectedErr); done(); }); - }) - }) + }); + }); - describe('when the promise takes too long to settle', function(){ + describe('when the promise takes too long to settle', function () { var foreverPendingPromise = { then: function () { } }; - it('should give the timeout error', function(done){ - var test = new Runnable('foo', function(){ + it('should give the timeout error', function (done) { + var test = new Runnable('foo', function () { return foreverPendingPromise; }); test.timeout(10); - test.run(function(err){ + test.run(function (err) { err.should.be.ok(); done(); }); - }) - }) - }) - - describe('when fn returns a non-promise', function(){ - it('should invoke the callback', function(done){ - var test = new Runnable('foo', function(){ - return { then: "i ran my tests" }; + }); + }); + }); + + describe('when fn returns a non-promise', function () { + it('should invoke the callback', function (done) { + var test = new Runnable('foo', function () { + return { then: 'i ran my tests' }; }); test.run(done); - }) - }) - }) -}) + }); + }); + }); +}); diff --git a/tests/lib/mocha-3.1.0/test/runner.spec.js b/tests/lib/mocha-3.1.2/test/runner.spec.js index 5392d0077b..7c69846ec8 100644 --- a/tests/lib/mocha-3.1.0/test/runner.spec.js +++ b/tests/lib/mocha-3.1.2/test/runner.spec.js @@ -1,23 +1,24 @@ +'use strict'; + var mocha = require('../'); var Suite = mocha.Suite; var Runner = mocha.Runner; var Test = mocha.Test; var Hook = mocha.Hook; var path = require('path'); +var noop = mocha.utils.noop; -function noop() {} - -describe('Runner', function() { +describe('Runner', function () { var suite; var runner; - beforeEach(function() { + beforeEach(function () { suite = new Suite('Suite', 'root'); runner = new Runner(suite); }); - describe('.grep()', function() { - it('should update the runner.total with number of matched tests', function() { + describe('.grep()', function () { + it('should update the runner.total with number of matched tests', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -26,7 +27,7 @@ describe('Runner', function() { newRunner.total.should.equal(2); }); - it('should update the runner.total with number of matched tests when inverted', function() { + it('should update the runner.total with number of matched tests when inverted', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -36,8 +37,8 @@ describe('Runner', function() { }); }); - describe('.grepTotal()', function() { - it('should return the total number of matched tests', function() { + describe('.grepTotal()', function () { + it('should return the total number of matched tests', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -45,7 +46,7 @@ describe('Runner', function() { runner.grepTotal(suite).should.equal(2); }); - it('should return the total number of matched tests when inverted', function() { + it('should return the total number of matched tests when inverted', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -54,8 +55,8 @@ describe('Runner', function() { }); }); - describe('.globalProps()', function() { - it('should include common non enumerable globals', function() { + describe('.globalProps()', function () { + it('should include common non enumerable globals', function () { var props = runner.globalProps(); props.should.containEql('setTimeout'); props.should.containEql('clearTimeout'); @@ -66,20 +67,20 @@ describe('Runner', function() { }); }); - describe('.globals()', function() { - it('should default to the known globals', function() { + describe('.globals()', function () { + it('should default to the known globals', function () { runner.globals().length.should.be.above(16); }); - it('should white-list globals', function() { + it('should white-list globals', function () { runner.globals(['foo', 'bar']); runner.globals().should.containEql('foo'); runner.globals().should.containEql('bar'); }); }); - describe('.checkGlobals(test)', function() { - it('should allow variables that match a wildcard', function(done) { + describe('.checkGlobals(test)', function () { + it('should allow variables that match a wildcard', function (done) { runner.globals(['foo*', 'giz*']); global.foo = 'baz'; global.gizmo = 'quux'; @@ -89,11 +90,11 @@ describe('Runner', function() { done(); }); - it('should emit "fail" when a new global is introduced', function(done) { + it('should emit "fail" when a new global is introduced', function (done) { var test = new Test('im a test', noop); runner.checkGlobals(); global.foo = 'bar'; - runner.on('fail', function(_test, err) { + runner.on('fail', function (_test, err) { _test.should.equal(test); err.message.should.equal('global leak detected: foo'); delete global.foo; @@ -102,11 +103,11 @@ describe('Runner', function() { runner.checkGlobals(test); }); - it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function(done) { + it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function (done) { var doneCalled = false; runner.globals('good'); global.bad = 1; - runner.on('fail', function() { + runner.on('fail', function () { delete global.bad; done(); doneCalled = true; @@ -117,7 +118,7 @@ describe('Runner', function() { } }); - it('should not fail when a new common global is introduced', function() { + it('should not fail when a new common global is introduced', function () { // verify that the prop isn't enumerable delete global.XMLHttpRequest; global.propertyIsEnumerable('XMLHttpRequest').should.not.be.ok(); @@ -128,7 +129,7 @@ describe('Runner', function() { var newRunner = new Runner(suite); // make the prop enumerable again. - global.XMLHttpRequest = function() {}; + global.XMLHttpRequest = function () {}; global.propertyIsEnumerable('XMLHttpRequest').should.be.ok(); // verify the test hasn't failed. @@ -139,12 +140,12 @@ describe('Runner', function() { delete global.XMLHttpRequest; }); - it('should pluralize the error message when several are introduced', function(done) { + it('should pluralize the error message when several are introduced', function (done) { var test = new Test('im a test', noop); runner.checkGlobals(); global.foo = 'bar'; global.bar = 'baz'; - runner.on('fail', function(_test, err) { + runner.on('fail', function (_test, err) { _test.should.equal(test); err.message.should.equal('global leaks detected: foo, bar'); delete global.foo; @@ -154,7 +155,7 @@ describe('Runner', function() { runner.checkGlobals(test); }); - it('should respect per test whitelisted globals', function() { + it('should respect per test whitelisted globals', function () { var test = new Test('im a test about lions', noop); test.globals(['foo']); @@ -170,7 +171,7 @@ describe('Runner', function() { delete global.foo; }); - it('should respect per test whitelisted globals but still detect other leaks', function(done) { + it('should respect per test whitelisted globals but still detect other leaks', function (done) { var test = new Test('im a test about lions', noop); test.globals(['foo']); @@ -178,7 +179,7 @@ describe('Runner', function() { global.foo = 'bar'; global.bar = 'baz'; - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { test.title.should.equal('im a test about lions'); err.message.should.equal('global leak detected: bar'); delete global.foo; @@ -187,32 +188,32 @@ describe('Runner', function() { runner.checkGlobals(test); }); - it('should emit "fail" when a global beginning with d is introduced', function(done) { + it('should emit "fail" when a global beginning with d is introduced', function (done) { global.derp = 'bar'; - runner.on('fail', function() { + runner.on('fail', function () { delete global.derp; done(); }); - runner.checkGlobals(new Test('herp', function() {})); + runner.checkGlobals(new Test('herp', function () {})); }); }); - describe('.hook(name, fn)', function() { - it('should execute hooks after failed test if suite bail is true', function(done) { + describe('.hook(name, fn)', function () { + it('should execute hooks after failed test if suite bail is true', function (done) { runner.fail(new Test('failed test', noop)); suite.bail(true); - suite.afterEach(function() { - suite.afterAll(function() { + suite.afterEach(function () { + suite.afterAll(function () { done(); }); }); - runner.hook('afterEach', function() {}); - runner.hook('afterAll', function() {}); + runner.hook('afterEach', function () {}); + runner.hook('afterAll', function () {}); }); }); - describe('.fail(test, err)', function() { - it('should increment .failures', function() { + describe('.fail(test, err)', function () { + it('should increment .failures', function () { runner.failures.should.equal(0); runner.fail(new Test('one', noop), {}); runner.failures.should.equal(1); @@ -220,16 +221,16 @@ describe('Runner', function() { runner.failures.should.equal(2); }); - it('should set test.state to "failed"', function() { + it('should set test.state to "failed"', function () { var test = new Test('some test', noop); runner.fail(test, 'some error'); test.state.should.equal('failed'); }); - it('should emit "fail"', function(done) { + it('should emit "fail"', function (done) { var test = new Test('some other test', noop); var err = {}; - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { test.should.equal(test); err.should.equal(err); done(); @@ -237,62 +238,77 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should emit a helpful message when failed with a string', function(done) { + it('should emit a helpful message when failed with a string', function (done) { var test = new Test('helpful test', noop); var err = 'string'; - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { err.message.should.equal('the string "string" was thrown, throw an Error :)'); done(); }); runner.fail(test, err); }); - it('should emit a the error when failed with an Error instance', function(done) { + it('should emit a the error when failed with an Error instance', function (done) { var test = new Test('a test', noop); var err = new Error('an error message'); - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { err.message.should.equal('an error message'); done(); }); runner.fail(test, err); }); - it('should emit the error when failed with an Error-like object', function(done) { + it('should emit the error when failed with an Error-like object', function (done) { var test = new Test('a test', noop); var err = { message: 'an error message' }; - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { err.message.should.equal('an error message'); done(); }); runner.fail(test, err); }); - it('should emit a helpful message when failed with an Object', function(done) { + it('should emit a helpful message when failed with an Object', function (done) { var test = new Test('a test', noop); var err = { x: 1 }; - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { err.message.should.equal('the object {\n "x": 1\n} was thrown, throw an Error :)'); done(); }); runner.fail(test, err); }); - it('should emit a helpful message when failed with an Array', function(done) { + it('should emit a helpful message when failed with an Array', function (done) { var test = new Test('a test', noop); var err = [ 1, 2 ]; - runner.on('fail', function(test, err) { + runner.on('fail', function (test, err) { err.message.should.equal('the array [\n 1\n 2\n] was thrown, throw an Error :)'); done(); }); runner.fail(test, err); }); + + it('should recover if the error stack is not writable', function (done) { + var err = new Error('not evil'); + Object.defineProperty(err, 'stack', { + value: err.stack + }); + var test = new Test('a test', noop); + + runner.on('fail', function (test, err) { + err.message.should.equal('not evil'); + done(); + }); + + runner.fail(test, err); + }); }); - describe('.failHook(hook, err)', function() { - it('should increment .failures', function() { + describe('.failHook(hook, err)', function () { + it('should increment .failures', function () { runner.failures.should.equal(0); runner.failHook(new Test('fail hook 1', noop), {}); runner.failures.should.equal(1); @@ -300,7 +316,7 @@ describe('Runner', function() { runner.failures.should.equal(2); }); - it('should augment hook title with current test title', function() { + it('should augment hook title with current test title', function () { var hook = new Hook('"before each" hook'); hook.ctx = { currentTest: new Test('should behave', noop) }; @@ -312,10 +328,10 @@ describe('Runner', function() { hook.title.should.equal('"before each" hook for "should obey"'); }); - it('should emit "fail"', function(done) { + it('should emit "fail"', function (done) { var hook = new Hook(); var err = {}; - runner.on('fail', function(hook, err) { + runner.on('fail', function (hook, err) { hook.should.equal(hook); err.should.equal(err); done(); @@ -323,7 +339,7 @@ describe('Runner', function() { runner.failHook(hook, err); }); - it('should emit "end" if suite bail is true', function(done) { + it('should emit "end" if suite bail is true', function (done) { var hook = new Hook(); var err = {}; suite.bail(true); @@ -331,11 +347,11 @@ describe('Runner', function() { runner.failHook(hook, err); }); - it('should not emit "end" if suite bail is not true', function(done) { + it('should not emit "end" if suite bail is not true', function (done) { var hook = new Hook(); var err = {}; suite.bail(false); - runner.on('end', function() { + runner.on('end', function () { throw new Error('"end" was emit, but the bail is false'); }); runner.failHook(hook, err); @@ -343,14 +359,14 @@ describe('Runner', function() { }); }); - describe('allowUncaught', function() { - it('should allow unhandled errors to propagate through', function(done) { + describe('allowUncaught', function () { + it('should allow unhandled errors to propagate through', function (done) { var newRunner = new Runner(suite); newRunner.allowUncaught = true; - newRunner.test = new Test('failing test', function() { + newRunner.test = new Test('failing test', function () { throw new Error('allow unhandled errors'); }); - function fail() { + function fail () { newRunner.runTest(); } fail.should.throw('allow unhandled errors'); @@ -358,7 +374,7 @@ describe('Runner', function() { }); }); - describe('stackTrace', function() { + describe('stackTrace', function () { var stack = [ 'AssertionError: foo bar', 'at EventEmitter.<anonymous> (/usr/local/dev/test.js:16:12)', @@ -373,20 +389,20 @@ describe('Runner', function() { 'at processImmediate [as _immediateCallback] (timers.js:321:17)' ]; - describe('shortStackTrace', function() { - beforeEach(function() { + describe('shortStackTrace', function () { + beforeEach(function () { if (path.sep !== '/') { this.skip(); } }); - it('should prettify the stack-trace', function(done) { + it('should prettify the stack-trace', function (done) { var hook = new Hook(); var err = new Error(); // Fake stack-trace err.stack = stack.join('\n'); - runner.on('fail', function(hook, err) { + runner.on('fail', function (hook, err) { err.stack.should.equal(stack.slice(0, 3).join('\n')); done(); }); @@ -394,14 +410,14 @@ describe('Runner', function() { }); }); - describe('longStackTrace', function() { - beforeEach(function() { + describe('longStackTrace', function () { + beforeEach(function () { if (path.sep !== '/') { this.skip(); } }); - it('should display the full stack-trace', function(done) { + it('should display the full stack-trace', function (done) { var hook = new Hook(); var err = new Error(); // Fake stack-trace @@ -409,7 +425,7 @@ describe('Runner', function() { // Add --stack-trace option runner.fullStackTrace = true; - runner.on('fail', function(hook, err) { + runner.on('fail', function (hook, err) { err.stack.should.equal(stack.join('\n')); done(); }); diff --git a/tests/lib/mocha-3.1.2/test/sanity/sanity.spec.js b/tests/lib/mocha-3.1.2/test/sanity/sanity.spec.js new file mode 100644 index 0000000000..b918f1c4f9 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/sanity/sanity.spec.js @@ -0,0 +1,9 @@ +'use strict'; + +var assert = require('assert'); + +describe('a production installation of Mocha', function () { + it('should be able to execute a test', function () { + assert.ok(true); + }); +}); diff --git a/tests/lib/mocha-3.1.2/test/setup.js b/tests/lib/mocha-3.1.2/test/setup.js new file mode 100644 index 0000000000..0ffe34c7e5 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/setup.js @@ -0,0 +1,4 @@ +'use strict'; + +global.expect = require('expect.js'); +global.assert = require('assert'); diff --git a/tests/lib/mocha-3.1.0/test/suite.spec.js b/tests/lib/mocha-3.1.2/test/suite.spec.js index 54a1acd667..4cb62dd290 100644 --- a/tests/lib/mocha-3.1.0/test/suite.spec.js +++ b/tests/lib/mocha-3.1.2/test/suite.spec.js @@ -1,11 +1,12 @@ -var mocha = require('../') - , Context = mocha.Context - , Suite = mocha.Suite - , Test = mocha.Test; - -describe('Suite', function(){ - describe('.clone()', function(){ - beforeEach(function(){ +'use strict'; + +var mocha = require('../'); +var Suite = mocha.Suite; +var Test = mocha.Test; + +describe('Suite', function () { + describe('.clone()', function () { + beforeEach(function () { this.suite = new Suite('To be cloned'); this.suite._timeout = 3043; this.suite._slow = 101; @@ -18,120 +19,120 @@ describe('Suite', function(){ this.suite._afterAll.push(5); }); - it('should copy the title', function(){ + it('should copy the title', function () { this.suite.clone().title.should.equal('To be cloned'); }); - it('should copy the timeout value', function(){ + it('should copy the timeout value', function () { this.suite.clone().timeout().should.equal(3043); }); - it('should copy the slow value', function(){ + it('should copy the slow value', function () { this.suite.clone().slow().should.equal(101); }); - it('should copy the bail value', function(){ + it('should copy the bail value', function () { this.suite.clone().bail().should.be.true(); }); - it('should not copy the values from the suites array', function(){ + it('should not copy the values from the suites array', function () { this.suite.clone().suites.should.be.empty(); }); - it('should not copy the values from the tests array', function(){ + it('should not copy the values from the tests array', function () { this.suite.clone().tests.should.be.empty(); }); - it('should not copy the values from the _beforeEach array', function(){ + it('should not copy the values from the _beforeEach array', function () { this.suite.clone()._beforeEach.should.be.empty(); }); - it('should not copy the values from the _beforeAll array', function(){ + it('should not copy the values from the _beforeAll array', function () { this.suite.clone()._beforeAll.should.be.empty(); }); - it('should not copy the values from the _afterEach array', function(){ + it('should not copy the values from the _afterEach array', function () { this.suite.clone()._afterEach.should.be.empty(); }); - it('should not copy the values from the _afterAll array', function(){ + it('should not copy the values from the _afterAll array', function () { this.suite.clone()._afterAll.should.be.empty(); }); }); - describe('.timeout()', function(){ - beforeEach(function(){ + describe('.timeout()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('when no argument is passed', function(){ - it('should return the timeout value', function(){ + describe('when no argument is passed', function () { + it('should return the timeout value', function () { this.suite.timeout().should.equal(2000); }); }); - describe('when argument is passed', function(){ - it('should return the Suite object', function(){ + describe('when argument is passed', function () { + it('should return the Suite object', function () { var newSuite = this.suite.timeout(5000); newSuite.timeout().should.equal(5000); }); }); }); - describe('.slow()', function(){ - beforeEach(function(){ + describe('.slow()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('when given a string', function(){ - it('should parse it', function(){ + describe('when given a string', function () { + it('should parse it', function () { this.suite.slow('5 seconds'); this.suite.slow().should.equal(5000); - }) - }) + }); + }); - describe('when no argument is passed', function(){ - it('should return the slow value', function(){ + describe('when no argument is passed', function () { + it('should return the slow value', function () { this.suite.slow().should.equal(75); }); }); - describe('when argument is passed', function(){ - it('should return the Suite object', function(){ + describe('when argument is passed', function () { + it('should return the Suite object', function () { var newSuite = this.suite.slow(5000); newSuite.slow().should.equal(5000); }); }); }); - describe('.bail()', function(){ - beforeEach(function(){ + describe('.bail()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); - this.suite._bail = true + this.suite._bail = true; }); - describe('when no argument is passed', function(){ - it('should return the bail value', function(){ + describe('when no argument is passed', function () { + it('should return the bail value', function () { this.suite.bail().should.be.true(); }); }); - describe('when argument is passed', function(){ - it('should return the Suite object', function(){ + describe('when argument is passed', function () { + it('should return the Suite object', function () { var newSuite = this.suite.bail(false); newSuite.bail().should.be.false(); }); }); }); - describe('.beforeAll()', function(){ - beforeEach(function(){ + describe('.beforeAll()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function(){ - it('adds it to _beforeAll', function(){ - var fn = function(){}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _beforeAll', function () { + var fn = function () {}; this.suite.beforeAll(fn); this.suite._beforeAll.should.have.length(1); @@ -140,8 +141,8 @@ describe('Suite', function(){ beforeAllItem.fn.should.equal(fn); }); - it('appends title to hook', function(){ - var fn = function(){}; + it('appends title to hook', function () { + var fn = function () {}; this.suite.beforeAll('test', fn); this.suite._beforeAll.should.have.length(1); @@ -149,7 +150,7 @@ describe('Suite', function(){ beforeAllItem.title.should.equal('"before all" hook: test'); beforeAllItem.fn.should.equal(fn); - function namedFn(){} + function namedFn () {} this.suite.beforeAll(namedFn); this.suite._beforeAll.should.have.length(2); beforeAllItem = this.suite._beforeAll[1]; @@ -159,14 +160,14 @@ describe('Suite', function(){ }); }); - describe('.afterAll()', function(){ - beforeEach(function(){ + describe('.afterAll()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function(){ - it('adds it to _afterAll', function(){ - var fn = function(){}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _afterAll', function () { + var fn = function () {}; this.suite.afterAll(fn); this.suite._afterAll.should.have.length(1); @@ -174,8 +175,8 @@ describe('Suite', function(){ afterAllItem.title.should.match(/^"after all" hook/); afterAllItem.fn.should.equal(fn); }); - it('appends title to hook', function(){ - var fn = function(){}; + it('appends title to hook', function () { + var fn = function () {}; this.suite.afterAll('test', fn); this.suite._afterAll.should.have.length(1); @@ -183,7 +184,7 @@ describe('Suite', function(){ beforeAllItem.title.should.equal('"after all" hook: test'); beforeAllItem.fn.should.equal(fn); - function namedFn(){} + function namedFn () {} this.suite.afterAll(namedFn); this.suite._afterAll.should.have.length(2); beforeAllItem = this.suite._afterAll[1]; @@ -193,14 +194,14 @@ describe('Suite', function(){ }); }); - describe('.beforeEach()', function(){ - beforeEach(function(){ + describe('.beforeEach()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function(){ - it('adds it to _beforeEach', function(){ - var fn = function(){}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _beforeEach', function () { + var fn = function () {}; this.suite.beforeEach(fn); this.suite._beforeEach.should.have.length(1); @@ -209,8 +210,8 @@ describe('Suite', function(){ beforeEachItem.fn.should.equal(fn); }); - it('appends title to hook', function(){ - var fn = function(){}; + it('appends title to hook', function () { + var fn = function () {}; this.suite.beforeEach('test', fn); this.suite._beforeEach.should.have.length(1); @@ -218,7 +219,7 @@ describe('Suite', function(){ beforeAllItem.title.should.equal('"before each" hook: test'); beforeAllItem.fn.should.equal(fn); - function namedFn(){} + function namedFn () {} this.suite.beforeEach(namedFn); this.suite._beforeEach.should.have.length(2); beforeAllItem = this.suite._beforeEach[1]; @@ -228,14 +229,14 @@ describe('Suite', function(){ }); }); - describe('.afterEach()', function(){ - beforeEach(function(){ + describe('.afterEach()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function(){ - it('adds it to _afterEach', function(){ - var fn = function(){}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _afterEach', function () { + var fn = function () {}; this.suite.afterEach(fn); this.suite._afterEach.should.have.length(1); @@ -244,8 +245,8 @@ describe('Suite', function(){ afterEachItem.fn.should.equal(fn); }); - it('appends title to hook', function(){ - var fn = function(){}; + it('appends title to hook', function () { + var fn = function () {}; this.suite.afterEach('test', fn); this.suite._afterEach.should.have.length(1); @@ -253,7 +254,7 @@ describe('Suite', function(){ beforeAllItem.title.should.equal('"after each" hook: test'); beforeAllItem.fn.should.equal(fn); - function namedFn(){} + function namedFn () {} this.suite.afterEach(namedFn); this.suite._afterEach.should.have.length(2); beforeAllItem = this.suite._afterEach[1]; @@ -263,8 +264,8 @@ describe('Suite', function(){ }); }); - describe('.addSuite()', function(){ - beforeEach(function(){ + describe('.addSuite()', function () { + beforeEach(function () { this.first = new Suite('First suite'); this.first.timeout(4002); this.first.slow(200); @@ -272,26 +273,26 @@ describe('Suite', function(){ this.first.addSuite(this.second); }); - it('sets the parent on the added Suite', function(){ + it('sets the parent on the added Suite', function () { this.second.parent.should.equal(this.first); }); - it('copies the timeout value', function(){ + it('copies the timeout value', function () { this.second.timeout().should.equal(4002); }); - it('copies the slow value', function(){ + it('copies the slow value', function () { this.second.slow().should.equal(200); }); - it('adds the suite to the suites collection', function(){ + it('adds the suite to the suites collection', function () { this.first.suites.should.have.length(1); this.first.suites[0].should.equal(this.second); }); - it('treats suite as pending if its parent is pending', function(){ - this.first.pending = true - this.second.isPending.should.be.true + it('treats suite as pending if its parent is pending', function () { + this.first.pending = true; + this.second.isPending.should.be.true; }); }); @@ -317,19 +318,19 @@ describe('Suite', function(){ // }); // }); - describe('.fullTitle()', function(){ - beforeEach(function(){ + describe('.fullTitle()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('when there is no parent', function(){ - it('returns the suite title', function(){ + describe('when there is no parent', function () { + it('returns the suite title', function () { this.suite.fullTitle().should.equal('A Suite'); }); }); - describe('when there is a parent', function(){ - it('returns the combination of parent\'s and suite\'s title', function(){ + describe('when there is a parent', function () { + it('returns the combination of parent\'s and suite\'s title', function () { var parentSuite = new Suite('I am a parent'); parentSuite.addSuite(this.suite); this.suite.fullTitle().should.equal('I am a parent A Suite'); @@ -337,19 +338,19 @@ describe('Suite', function(){ }); }); - describe('.total()', function(){ - beforeEach(function(){ + describe('.total()', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('when there are no nested suites or tests', function(){ - it('should return 0', function(){ + describe('when there are no nested suites or tests', function () { + it('should return 0', function () { this.suite.total().should.equal(0); }); }); - describe('when there are several tests in the suite', function(){ - it('should return the number', function(){ + describe('when there are several tests in the suite', function () { + it('should return the number', function () { this.suite.addTest(new Test('a child test')); this.suite.addTest(new Test('another child test')); this.suite.total().should.equal(2); @@ -357,83 +358,83 @@ describe('Suite', function(){ }); }); - describe('.eachTest(fn)', function(){ - beforeEach(function(){ + describe('.eachTest(fn)', function () { + beforeEach(function () { this.suite = new Suite('A Suite'); }); - describe('when there are no nested suites or tests', function(){ - it('should return 0', function(){ + describe('when there are no nested suites or tests', function () { + it('should return 0', function () { var n = 0; - function fn(){ n++; } + function fn () { n++; } this.suite.eachTest(fn); n.should.equal(0); }); }); - describe('when there are several tests in the suite', function(){ - it('should return the number', function(){ + describe('when there are several tests in the suite', function () { + it('should return the number', function () { this.suite.addTest(new Test('a child test')); this.suite.addTest(new Test('another child test')); var n = 0; - function fn(){ n++; } + function fn () { n++; } this.suite.eachTest(fn); n.should.equal(2); }); }); - describe('when there are several levels of nested suites', function(){ - it('should return the number', function(){ + describe('when there are several levels of nested suites', function () { + it('should return the number', function () { this.suite.addTest(new Test('a child test')); var suite = new Suite('a child suite'); suite.addTest(new Test('a test in a child suite')); this.suite.addSuite(suite); var n = 0; - function fn(){ n++; } + function fn () { n++; } this.suite.eachTest(fn); n.should.equal(2); }); }); - }); - describe('initialization', function() { - it('should throw an error if the title isn\'t a string', function() { - (function() { + describe('initialization', function () { + /* eslint no-new: off */ + it('should throw an error if the title isn\'t a string', function () { + (function () { new Suite(undefined, 'root'); }).should.throw(); - (function() { - new Suite(function(){}, 'root'); + (function () { + new Suite(function () {}, 'root'); }).should.throw(); }); - it('should not throw if the title is a string', function() { - (function() { + it('should not throw if the title is a string', function () { + (function () { new Suite('Bdd suite', 'root'); }).should.not.throw(); }); }); }); -describe('Test', function() { - describe('initialization', function() { - it('should throw an error if the title isn\'t a string', function() { - (function() { - new Test(function(){}); +describe('Test', function () { + describe('initialization', function () { + it('should throw an error if the title isn\'t a string', function () { + (function () { + new Test(function () {}); }).should.throw(); - (function() { - new Test(undefined, function(){}); + (function () { + new Test(undefined, function () {}); }).should.throw(); }); - it('should not throw if the title is a string', function() { - (function() { - new Test('test-case', function(){}); + it('should not throw if the title is a string', function () { + (function () { + new Test('test-case', function () {}); }).should.not.throw(); }); }); -});
\ No newline at end of file +}); diff --git a/tests/lib/mocha-3.1.0/test/test.spec.js b/tests/lib/mocha-3.1.2/test/test.spec.js index 5dea7919db..73c09b3b06 100644 --- a/tests/lib/mocha-3.1.0/test/test.spec.js +++ b/tests/lib/mocha-3.1.2/test/test.spec.js @@ -1,11 +1,12 @@ -var mocha = require('../') - , should = require('should') - , Context = mocha.Context - , Test = mocha.Test; +'use strict'; -describe('Test', function(){ - describe('.clone()', function(){ - beforeEach(function(){ +var mocha = require('../'); +var should = require('should'); +var Test = mocha.Test; + +describe('Test', function () { + describe('.clone()', function () { + beforeEach(function () { this._test = new Test('To be cloned', function () {}); this._test._timeout = 3043; this._test._slow = 101; @@ -17,59 +18,59 @@ describe('Test', function(){ this._test.file = 'bar'; }); - it('should copy the title', function(){ + it('should copy the title', function () { this._test.clone().title.should.equal('To be cloned'); }); - it('should copy the timeout value', function(){ + it('should copy the timeout value', function () { this._test.clone().timeout().should.equal(3043); }); - it('should copy the slow value', function(){ + it('should copy the slow value', function () { this._test.clone().slow().should.equal(101); }); - it('should copy the enableTimeouts value', function(){ + it('should copy the enableTimeouts value', function () { this._test.clone().enableTimeouts().should.be.true(); }); - it('should copy the retries value', function(){ + it('should copy the retries value', function () { this._test.clone().retries().should.equal(3); }); - it('should copy the currentRetry value', function(){ + it('should copy the currentRetry value', function () { this._test.clone().currentRetry().should.equal(1); }); - it('should copy the globals value', function(){ + it('should copy the globals value', function () { this._test.clone().globals().should.not.be.empty(); }); - it('should copy the parent value', function(){ + it('should copy the parent value', function () { this._test.clone().parent.should.equal('foo'); }); - it('should copy the file value', function(){ + it('should copy the file value', function () { this._test.clone().file.should.equal('bar'); }); }); - describe('.isPending()', function(){ - beforeEach(function(){ + describe('.isPending()', function () { + beforeEach(function () { this._test = new Test('Is it skipped', function () {}); }); - it('should not be pending by default', function(){ + it('should not be pending by default', function () { should(this._test.isPending()).not.be.ok(); }); - it('should be pending when marked as such', function(){ + it('should be pending when marked as such', function () { this._test.pending = true; should(this._test.isPending()).be.ok(); }); - it('should be pending when its parent is pending', function(){ - this._test.parent = { isPending: function(){ return true } }; + it('should be pending when its parent is pending', function () { + this._test.parent = { isPending: function () { return true; } }; should(this._test.isPending()).be.ok(); }); }); diff --git a/tests/lib/mocha-3.1.0/test/utils.spec.js b/tests/lib/mocha-3.1.2/test/utils.spec.js index 4683809ae6..ccfd861a78 100644 --- a/tests/lib/mocha-3.1.0/test/utils.spec.js +++ b/tests/lib/mocha-3.1.2/test/utils.spec.js @@ -1,86 +1,88 @@ +'use strict'; + var mocha = require('..'); var utils = mocha.utils; var path = require('path'); var JSON = require('json3'); -describe('utils', function() { - describe('.clean()', function() { +describe('utils', function () { + describe('.clean()', function () { var clean = utils.clean; - it('should remove the wrapping function declaration', function() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + it('should handle empty functions', function () { clean('function() {}').should.equal(''); }); }); - describe('.isBuffer()', function() { + describe('.isBuffer()', function () { var isBuffer = utils.isBuffer; - it('should test if object is a Buffer', function() { + it('should test if object is a Buffer', function () { isBuffer(new Buffer([0x01])).should.equal(true); isBuffer({}).should.equal(false); - }) + }); }); - describe('.map()', function() { + describe('.map()', function () { var map = utils.map; - it('should behave same as Array.prototype.map', function() { + 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() { + it('should call the callback with 3 arguments[currentValue, index, array]', function () { var index = 0; - map([1, 2, 3], function(e, i, arr) { + 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() { + it('should apply with the given scope', function () { var scope = {}; - map(['a', 'b', 'c'], function() { + map(['a', 'b', 'c'], function () { this.should.equal(scope); }, scope); }); }); - describe('.parseQuery()', function() { + describe('.parseQuery()', function () { var parseQuery = utils.parseQuery; - it('should get queryString and return key-value object', function() { + it('should get queryString and return key-value object', function () { parseQuery('?foo=1&bar=2&baz=3').should.eql({ foo: '1', bar: '2', @@ -92,11 +94,11 @@ describe('utils', function() { r2: 'm{2}', r3: '^co.*' }); - }) + }); }); - describe('.stackTraceFilter()', function() { - describe('on node', function() { + describe('.stackTraceFilter()', function () { + describe('on node', function () { var filter = utils.stackTraceFilter(); describe('on POSIX OS', function () { @@ -187,7 +189,7 @@ describe('utils', function() { }); }); - describe('on Windows', function() { + describe('on Windows', function () { before(function () { if (path.sep === '/') { this.skip(); @@ -215,44 +217,46 @@ describe('utils', function() { }); }); - describe('on browser', function() { + describe('on browser', function () { var filter; - before(function() { + 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')); + 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() { + 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; + 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() { + 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() { + it('should return false if the value is an object w/o a "then" function', function () { utils.isPromise({}).should.be.false; }); }); |