Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fix CI; closes #2867 (#2868)

Christopher Hiller50fc47d1b46c
diff --git a/karma.conf.js b/karma.conf.js
index c99150e2..b8d73fd0 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -14,6 +14,15 @@ module.exports = function (config) {
'expect',
'mocha'
],
+ plugins: [
+ 'karma-browserify',
+ 'karma-chrome-launcher',
+ 'karma-phantomjs-launcher',
+ 'karma-expect',
+ 'karma-mocha',
+ 'karma-spec-reporter',
+ require('@coderbyheart/karma-sauce-launcher')
+ ],
files: [
// we use the BDD interface for all of the tests that
// aren't interface-specific.
diff --git a/package.json b/package.json
index 562a182a..e772d902 100644
--- a/package.json
+++ b/package.json
@@ -320,6 +320,7 @@
"supports-color": "3.1.2"
},
"devDependencies": {
+ "@coderbyheart/karma-sauce-launcher": "coderbyheart/karma-sauce-launcher#5259942cd6d40090eaa13ceeef5b0b8738c7710f",
"assert": "^1.4.1",
"browserify": "^13.0.0",
"coffee-script": "^1.10.0",
@@ -337,7 +338,6 @@
"karma-expect": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "0.2.3",
- "karma-sauce-launcher": "coderbyheart/karma-sauce-launcher",
"karma-spec-reporter": "0.0.26",
"nyc": "^10.0.0",
"os-name": "^2.0.1",
diff --git a/test/jsapi/index.js b/test/jsapi/index.js
index 430a2052..d011c233 100644
--- a/test/jsapi/index.js
+++ b/test/jsapi/index.js
@@ -9,8 +9,7 @@ var mocha = new Mocha({
growl: true
});
-// mocha.reporter('spec');
-require('should');
+global.expect = require('expect.js');
mocha.addFile('test/unit/suite.spec.js');
mocha.addFile('test/unit/runner.spec.js');
diff --git a/test/unit/grep.spec.js b/test/unit/grep.spec.js
index bb620f9b..0e9b60ef 100644
--- a/test/unit/grep.spec.js
+++ b/test/unit/grep.spec.js
@@ -6,19 +6,19 @@ 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.*/');
+ expect(mocha.options.grep.toString()).to.equal('/foo.*/');
});
it('should convert string to a RegExp', function () {
var mocha = new Mocha({ grep: 'foo.*' });
- mocha.options.grep.toString().should.equal('/foo.*/');
+ expect(mocha.options.grep.toString()).to.equal('/foo.*/');
});
});
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\\.\\*/');
+ expect(mocha.options.grep.toString()).to.equal('/foo\\.\\*/');
});
});
@@ -27,7 +27,7 @@ describe('Mocha', function () {
function testGrep (mocha) {
return function testGrep (grep, expected) {
mocha.grep(grep);
- mocha.options.grep.toString().should.equal(expected);
+ expect(mocha.options.grep.toString()).to.equal(expected);
};
}
@@ -54,14 +54,14 @@ describe('Mocha', function () {
it('should return it\'s parent Mocha object for chainability', function () {
var mocha = new Mocha();
- mocha.grep().should.equal(mocha);
+ expect(mocha.grep()).to.equal(mocha);
});
});
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;
+ expect(mocha.options.invert).to.be.ok;
});
});
});
diff --git a/test/unit/hook-async.spec.js b/test/unit/hook-async.spec.js
index a03821e3..523abd2d 100644
--- a/test/unit/hook-async.spec.js
+++ b/test/unit/hook-async.spec.js
@@ -9,7 +9,7 @@ describe('async', function () {
after(function () {
calls.push('root after all');
- calls.should.eql([
+ expect(calls).to.eql([
'root before all',
'before all',
'parent before',
@@ -67,7 +67,7 @@ describe('async', function () {
});
it('one', function (done) {
- calls.should.eql([
+ expect(calls).to.eql([
'root before all',
'before all',
'parent before',
@@ -79,7 +79,7 @@ describe('async', function () {
});
it('two', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'root before all',
'before all',
'parent before',
@@ -97,7 +97,7 @@ describe('async', function () {
});
it('three', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'root before all',
'before all',
'parent before',
diff --git a/test/unit/hook-sync-nested.spec.js b/test/unit/hook-sync-nested.spec.js
index 3f1929f5..25f9a738 100644
--- a/test/unit/hook-sync-nested.spec.js
+++ b/test/unit/hook-sync-nested.spec.js
@@ -19,7 +19,7 @@ describe('serial', function () {
});
it('foo', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'parent before test foo'
]);
@@ -27,7 +27,7 @@ describe('serial', function () {
});
it('bar', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'parent before test foo',
'foo',
@@ -47,7 +47,7 @@ describe('serial', function () {
});
it('one', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'parent before test foo',
'foo',
@@ -66,7 +66,7 @@ describe('serial', function () {
});
it('two', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'parent before test foo',
'foo',
diff --git a/test/unit/hook-sync.spec.js b/test/unit/hook-sync.spec.js
index b1138a6d..3f2b0508 100644
--- a/test/unit/hook-sync.spec.js
+++ b/test/unit/hook-sync.spec.js
@@ -20,7 +20,7 @@ describe('serial', function () {
});
it('one', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'before',
'before test one'
@@ -29,7 +29,7 @@ describe('serial', function () {
});
it('two', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'before',
'before test one',
@@ -45,7 +45,7 @@ describe('serial', function () {
});
it('three', function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'before',
'before test one',
@@ -75,7 +75,7 @@ describe('serial', function () {
});
after(function () {
- calls.should.eql([
+ expect(calls).to.eql([
'parent before',
'before',
'before test one',
diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js
index af0c44a7..8f3b6eef 100644
--- a/test/unit/mocha.spec.js
+++ b/test/unit/mocha.spec.js
@@ -27,7 +27,7 @@ describe('Mocha', function () {
});
mocha.suite.addTest(failingTest);
mocha.run(function (failures) {
- failures.should.equal(1);
+ expect(failures).to.equal(1);
done();
});
});
diff --git a/test/unit/ms.spec.js b/test/unit/ms.spec.js
index 6ceab5d4..189e1264 100644
--- a/test/unit/ms.spec.js
+++ b/test/unit/ms.spec.js
@@ -11,72 +11,72 @@ describe('.ms()', 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');
+ expect(ms(200)).to.equal('200ms');
+ expect(ms(30)).to.equal('30ms');
+ expect(ms(2000)).to.not.equal('2000ms');
});
});
describe('seconds representation', function () {
it('should return short format', function () {
- ms(2000).should.equal('2s');
+ expect(ms(2000)).to.equal('2s');
});
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');
+ expect(ms(2000, { long: true })).to.equal('2 seconds');
+ expect(ms(1000, { long: true })).to.equal('1 second');
+ expect(ms(1010, { long: true })).to.equal('1 second');
});
});
describe('minutess representation', function () {
it('should return short format', function () {
- ms(time.minutes(1)).should.equal('1m');
+ expect(ms(time.minutes(1))).to.equal('1m');
});
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');
+ expect(ms(time.minutes(1), { long: true })).to.equal('1 minute');
+ expect(ms(time.minutes(3), { long: true })).to.equal('3 minutes');
});
});
describe('hours representation', function () {
it('should return short format', function () {
- ms(time.hours(1)).should.equal('1h');
+ expect(ms(time.hours(1))).to.equal('1h');
});
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');
+ expect(ms(time.hours(1), { long: true })).to.equal('1 hour');
+ expect(ms(time.hours(3), { long: true })).to.equal('3 hours');
});
});
describe('days representation', function () {
it('should return short format', function () {
- ms(time.days(1)).should.equal('1d');
+ expect(ms(time.days(1))).to.equal('1d');
});
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');
+ expect(ms(time.days(1), { long: true })).to.equal('1 day');
+ expect(ms(time.days(3), { long: true })).to.equal('3 days');
});
});
describe('Getting string value', function () {
it('should return the milliseconds representation(Number)', function () {
- ms('1 second').should.equal(1000);
+ expect(ms('1 second')).to.equal(1000);
- ms('1 minute').should.equal(time.minutes(1));
- ms('6 minutes').should.equal(time.minutes(6));
+ expect(ms('1 minute')).to.equal(time.minutes(1));
+ expect(ms('6 minutes')).to.equal(time.minutes(6));
- ms('1 hour').should.equal(time.hours(1));
- ms('5 hours').should.equal(time.hours(5));
+ expect(ms('1 hour')).to.equal(time.hours(1));
+ expect(ms('5 hours')).to.equal(time.hours(5));
- ms('1 day').should.equal(time.days(1));
- ms('3 days').should.equal(time.days(3));
+ expect(ms('1 day')).to.equal(time.days(1));
+ expect(ms('3 days')).to.equal(time.days(3));
- ms('1 year').should.equal(time.years(1));
- ms('2 years').should.equal(time.years(2));
+ expect(ms('1 year')).to.equal(time.years(1));
+ expect(ms('2 years')).to.equal(time.years(2));
});
});
});
diff --git a/test/unit/runnable.spec.js b/test/unit/runnable.spec.js
index 59bffff7..8c084281 100644
--- a/test/unit/runnable.spec.js
+++ b/test/unit/runnable.spec.js
@@ -38,7 +38,7 @@ describe('Runnable(title, fn)', function () {
it('should set the timeout', function () {
var run = new Runnable();
run.timeout(1000);
- run.timeout().should.equal(1000);
+ expect(run.timeout()).to.equal(1000);
});
});
@@ -46,7 +46,7 @@ describe('Runnable(title, fn)', function () {
it('should set disabled', function () {
var run = new Runnable();
run.timeout(1e10);
- run.enableTimeouts().should.be.false;
+ expect(run.enableTimeouts()).to.equal(false);
});
});
@@ -54,7 +54,7 @@ describe('Runnable(title, fn)', function () {
it('should set enabled', function () {
var run = new Runnable();
run.enableTimeouts(false);
- run.enableTimeouts().should.equal(false);
+ expect(run.enableTimeouts()).to.equal(false);
});
});
@@ -67,47 +67,47 @@ describe('Runnable(title, fn)', function () {
it('should set the slow threshold', function () {
run.slow(100);
- run.slow().should.equal(100);
+ expect(run.slow()).to.equal(100);
});
it('should not set the slow threshold if the parameter is not passed', function () {
run.slow();
- run.slow().should.equal(75);
+ expect(run.slow()).to.equal(75);
});
it('should not set the slow threshold if the parameter is undefined', function () {
run.slow(undefined);
- run.slow().should.equal(75);
+ expect(run.slow()).to.equal(75);
});
});
describe('.title', function () {
it('should be present', function () {
- new Runnable('foo').title.should.equal('foo');
+ expect(new Runnable('foo').title).to.equal('foo');
});
});
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();
+ expect(run.async).to.equal(1);
+ expect(run.sync).to.be(false);
});
});
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();
+ expect(run.async).to.be.equal(0);
+ expect(run.sync).to.be(true);
});
});
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();
+ expect(test.async).to.be.equal(0);
+ expect(test.sync).to.be(true);
test.globals(['foobar']);
test.run(done);
});
@@ -117,7 +117,7 @@ describe('Runnable(title, fn)', function () {
it('should set the number of retries', function () {
var run = new Runnable();
run.retries(1);
- run.retries().should.equal(1);
+ expect(run.retries()).to.equal(1);
});
});
@@ -142,9 +142,24 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- calls.should.equal(1);
- test.duration.should.be.type('number');
- done(err);
+ if (err) {
+ done(err);
+ return;
+ }
+
+ try {
+ expect(calls)
+ .to
+ .equal(1);
+ expect(test.duration)
+ .to
+ .be
+ .a('number');
+ } catch (err) {
+ done(err);
+ return;
+ }
+ done();
});
});
});
@@ -158,8 +173,8 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- calls.should.equal(1);
- err.message.should.equal('fail');
+ expect(calls).to.equal(1);
+ expect(err.message).to.equal('fail');
done();
});
});
@@ -174,7 +189,7 @@ describe('Runnable(title, fn)', function () {
function fail () {
test.run(function () {});
}
- fail.should.throw('fail');
+ expect(fail).to.throwError('fail');
done();
});
});
@@ -219,9 +234,9 @@ describe('Runnable(title, fn)', function () {
test.on('error', function (err) {
++errCalls;
- err.message.should.equal('done() called multiple times');
- calls.should.equal(1);
- errCalls.should.equal(1);
+ expect(err.message).to.equal('done() called multiple times');
+ expect(calls).to.equal(1);
+ expect(errCalls).to.equal(1);
done();
});
@@ -246,9 +261,9 @@ describe('Runnable(title, fn)', function () {
test.on('error', function (err) {
++errCalls;
- err.message.should.equal('fail');
- calls.should.equal(1);
- errCalls.should.equal(1);
+ expect(err.message).to.equal('fail');
+ expect(calls).to.equal(1);
+ expect(errCalls).to.equal(1);
done();
});
@@ -266,7 +281,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.message.should.equal('fail');
+ expect(err.message).to.equal('fail');
done();
});
});
@@ -278,7 +293,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.message.should.equal(utils.undefinedError().message);
+ expect(err.message).to.equal(utils.undefinedError().message);
done();
});
});
@@ -293,7 +308,7 @@ describe('Runnable(title, fn)', function () {
function fail () {
test.run(function () {});
}
- fail.should.throw('fail');
+ expect(fail).to.throwError('fail');
done();
});
});
@@ -305,7 +320,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.message.should.equal('fail');
+ expect(err.message).to.equal('fail');
done();
});
});
@@ -318,7 +333,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.message.should.equal('done() invoked with non-Error: {"error":"Test error"}');
+ expect(err.message).to.equal('done() invoked with non-Error: {"error":"Test error"}');
done();
});
});
@@ -331,7 +346,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.message.should.equal('done() invoked with non-Error: Test error');
+ expect(err.message).to.equal('done() invoked with non-Error: Test error');
done();
});
});
@@ -346,10 +361,10 @@ describe('Runnable(title, fn)', function () {
setTimeout(increment, 1);
setTimeout(increment, 100);
});
- test.timeout(10);
+ test.timeout(50);
test.run(function (err) {
- err.should.be.ok();
- callCount.should.equal(1);
+ expect(err).to.be.ok();
+ expect(callCount).to.equal(1);
done();
});
});
@@ -408,7 +423,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.should.equal(expectedErr);
+ expect(err).to.equal(expectedErr);
done();
});
});
@@ -430,7 +445,7 @@ describe('Runnable(title, fn)', function () {
});
test.run(function (err) {
- err.should.eql(expectedErr);
+ expect(err.message).to.equal(expectedErr.message);
done();
});
});
@@ -448,7 +463,7 @@ describe('Runnable(title, fn)', function () {
test.timeout(10);
test.run(function (err) {
- err.should.be.ok();
+ expect(err).to.be.ok();
done();
});
});
diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js
index c3dc379d..718a9b7c 100644
--- a/test/unit/runner.spec.js
+++ b/test/unit/runner.spec.js
@@ -24,7 +24,7 @@ describe('Runner', function () {
suite.addTest(new Test('im a test about bears', noop));
var newRunner = new Runner(suite);
newRunner.grep(/lions/);
- newRunner.total.should.equal(2);
+ expect(newRunner.total).to.equal(2);
});
it('should update the runner.total with number of matched tests when inverted', function () {
@@ -33,7 +33,7 @@ describe('Runner', function () {
suite.addTest(new Test('im a test about bears', noop));
var newRunner = new Runner(suite);
newRunner.grep(/lions/, true);
- newRunner.total.should.equal(1);
+ expect(newRunner.total).to.equal(1);
});
});
@@ -43,7 +43,7 @@ describe('Runner', function () {
suite.addTest(new Test('im another test about lions', noop));
suite.addTest(new Test('im a test about bears', noop));
runner.grep(/lions/);
- runner.grepTotal(suite).should.equal(2);
+ expect(runner.grepTotal(suite)).to.equal(2);
});
it('should return the total number of matched tests when inverted', function () {
@@ -51,35 +51,41 @@ describe('Runner', function () {
suite.addTest(new Test('im another test about lions', noop));
suite.addTest(new Test('im a test about bears', noop));
runner.grep(/lions/, true);
- runner.grepTotal(suite).should.equal(1);
+ expect(runner.grepTotal(suite)).to.equal(1);
});
});
describe('.globalProps()', function () {
it('should include common non enumerable globals', function () {
var props = runner.globalProps();
- props.should.containEql('setTimeout');
- props.should.containEql('clearTimeout');
- props.should.containEql('setInterval');
- props.should.containEql('clearInterval');
- props.should.containEql('Date');
- props.should.containEql('XMLHttpRequest');
+ expect(props).to.contain('setTimeout');
+ expect(props).to.contain('clearTimeout');
+ expect(props).to.contain('setInterval');
+ expect(props).to.contain('clearInterval');
+ expect(props).to.contain('Date');
+ expect(props).to.contain('XMLHttpRequest');
});
});
describe('.globals()', function () {
it('should default to the known globals', function () {
- runner.globals().length.should.be.above(16);
+ expect(runner.globals().length).to.be.above(16);
});
it('should white-list globals', function () {
runner.globals(['foo', 'bar']);
- runner.globals().should.containEql('foo');
- runner.globals().should.containEql('bar');
+ expect(runner.globals()).to.contain('foo');
+ expect(runner.globals()).to.contain('bar');
});
});
describe('.checkGlobals(test)', function () {
+ before(function () {
+ if (!Object.create) {
+ this.skip();
+ }
+ });
+
it('should allow variables that match a wildcard', function (done) {
runner.globals(['foo*', 'giz*']);
global.foo = 'baz';
@@ -95,8 +101,8 @@ describe('Runner', function () {
runner.checkGlobals();
global.foo = 'bar';
runner.on('fail', function (_test, err) {
- _test.should.equal(test);
- err.message.should.equal('global leak detected: foo');
+ expect(_test).to.equal(test);
+ expect(err.message).to.equal('global leak detected: foo');
delete global.foo;
done();
});
@@ -119,9 +125,12 @@ describe('Runner', function () {
});
it('should not fail when a new common global is introduced', function () {
+ if (process.browser) {
+ this.skip();
+ return;
+ }
// verify that the prop isn't enumerable
- delete global.XMLHttpRequest;
- global.propertyIsEnumerable('XMLHttpRequest').should.not.be.ok();
+ expect(global.propertyIsEnumerable('XMLHttpRequest')).to.not.be.ok();
// create a new runner and keep a reference to the test.
var test = new Test('im a test about bears', noop);
@@ -130,11 +139,11 @@ describe('Runner', function () {
// make the prop enumerable again.
global.XMLHttpRequest = function () {};
- global.propertyIsEnumerable('XMLHttpRequest').should.be.ok();
+ expect(global.propertyIsEnumerable('XMLHttpRequest')).to.be.ok();
// verify the test hasn't failed.
newRunner.checkGlobals(test);
- test.should.not.have.key('state');
+ expect(test).to.not.have.key('state');
// clean up our global space.
delete global.XMLHttpRequest;
@@ -146,8 +155,8 @@ describe('Runner', function () {
global.foo = 'bar';
global.bar = 'baz';
runner.on('fail', function (_test, err) {
- _test.should.equal(test);
- err.message.should.equal('global leaks detected: foo, bar');
+ expect(_test).to.equal(test);
+ expect(err.message).to.equal('global leaks detected: foo, bar');
delete global.foo;
delete global.bar;
done();
@@ -166,7 +175,7 @@ describe('Runner', function () {
// verify the test hasn't failed.
runner.checkGlobals(test);
- test.should.not.have.key('state');
+ expect(test).to.not.have.key('state');
delete global.foo;
});
@@ -180,8 +189,8 @@ describe('Runner', function () {
global.foo = 'bar';
global.bar = 'baz';
runner.on('fail', function (test, err) {
- test.title.should.equal('im a test about lions');
- err.message.should.equal('global leak detected: bar');
+ expect(test.title).to.equal('im a test about lions');
+ expect(err.message).to.equal('global leak detected: bar');
delete global.foo;
done();
});
@@ -214,25 +223,25 @@ describe('Runner', function () {
describe('.fail(test, err)', function () {
it('should increment .failures', function () {
- runner.failures.should.equal(0);
+ expect(runner.failures).to.equal(0);
runner.fail(new Test('one', noop), {});
- runner.failures.should.equal(1);
+ expect(runner.failures).to.equal(1);
runner.fail(new Test('two', noop), {});
- runner.failures.should.equal(2);
+ expect(runner.failures).to.equal(2);
});
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');
+ expect(test.state).to.equal('failed');
});
it('should emit "fail"', function (done) {
var test = new Test('some other test', noop);
var err = {};
runner.on('fail', function (test, err) {
- test.should.equal(test);
- err.should.equal(err);
+ expect(test).to.equal(test);
+ expect(err).to.equal(err);
done();
});
runner.fail(test, err);
@@ -242,7 +251,7 @@ describe('Runner', function () {
var test = new Test('helpful test', noop);
var err = 'string';
runner.on('fail', function (test, err) {
- err.message.should.equal('the string "string" was thrown, throw an Error :)');
+ expect(err.message).to.equal('the string "string" was thrown, throw an Error :)');
done();
});
runner.fail(test, err);
@@ -252,7 +261,7 @@ describe('Runner', function () {
var test = new Test('a test', noop);
var err = new Error('an error message');
runner.on('fail', function (test, err) {
- err.message.should.equal('an error message');
+ expect(err.message).to.equal('an error message');
done();
});
runner.fail(test, err);
@@ -262,7 +271,7 @@ describe('Runner', function () {
var test = new Test('a test', noop);
var err = { message: 'an error message' };
runner.on('fail', function (test, err) {
- err.message.should.equal('an error message');
+ expect(err.message).to.equal('an error message');
done();
});
runner.fail(test, err);
@@ -272,7 +281,7 @@ describe('Runner', function () {
var test = new Test('a test', noop);
var err = { x: 1 };
runner.on('fail', function (test, err) {
- err.message.should.equal('the object {\n "x": 1\n} was thrown, throw an Error :)');
+ expect(err.message).to.equal('the object {\n "x": 1\n} was thrown, throw an Error :)');
done();
});
runner.fail(test, err);
@@ -285,13 +294,18 @@ describe('Runner', function () {
2
];
runner.on('fail', function (test, err) {
- err.message.should.equal('the array [\n 1\n 2\n] was thrown, throw an Error :)');
+ expect(err.message).to.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) {
+ if (!Object.create) {
+ this.skip();
+ return;
+ }
+
var err = new Error('not evil');
Object.defineProperty(err, 'stack', {
value: err.stack
@@ -299,7 +313,7 @@ describe('Runner', function () {
var test = new Test('a test', noop);
runner.on('fail', function (test, err) {
- err.message.should.equal('not evil');
+ expect(err.message).to.equal('not evil');
done();
});
@@ -309,11 +323,11 @@ describe('Runner', function () {
describe('.failHook(hook, err)', function () {
it('should increment .failures', function () {
- runner.failures.should.equal(0);
+ expect(runner.failures).to.equal(0);
runner.failHook(new Test('fail hook 1', noop), {});
- runner.failures.should.equal(1);
+ expect(runner.failures).to.equal(1);
runner.failHook(new Test('fail hook 2', noop), {});
- runner.failures.should.equal(2);
+ expect(runner.failures).to.equal(2);
});
it('should augment hook title with current test title', function () {
@@ -321,19 +335,19 @@ describe('Runner', function () {
hook.ctx = { currentTest: new Test('should behave', noop) };
runner.failHook(hook, {});
- hook.title.should.equal('"before each" hook for "should behave"');
+ expect(hook.title).to.equal('"before each" hook for "should behave"');
hook.ctx.currentTest = new Test('should obey', noop);
runner.failHook(hook, {});
- hook.title.should.equal('"before each" hook for "should obey"');
+ expect(hook.title).to.equal('"before each" hook for "should obey"');
});
it('should emit "fail"', function (done) {
var hook = new Hook();
var err = {};
runner.on('fail', function (hook, err) {
- hook.should.equal(hook);
- err.should.equal(err);
+ expect(hook).to.equal(hook);
+ expect(err).to.equal(err);
done();
});
runner.failHook(hook, err);
@@ -369,7 +383,7 @@ describe('Runner', function () {
function fail () {
newRunner.runTest();
}
- fail.should.throw('allow unhandled errors');
+ expect(fail).to.throwError('allow unhandled errors');
done();
});
});
@@ -403,7 +417,7 @@ describe('Runner', function () {
err.stack = stack.join('\n');
runner.on('fail', function (hook, err) {
- err.stack.should.equal(stack.slice(0, 3).join('\n'));
+ expect(err.stack).to.equal(stack.slice(0, 3).join('\n'));
done();
});
runner.failHook(hook, err);
@@ -426,7 +440,7 @@ describe('Runner', function () {
runner.fullStackTrace = true;
runner.on('fail', function (hook, err) {
- err.stack.should.equal(stack.join('\n'));
+ expect(err.stack).to.equal(stack.join('\n'));
done();
});
runner.failHook(hook, err);
diff --git a/test/unit/suite.spec.js b/test/unit/suite.spec.js
index 4233f957..a4530e3c 100644
--- a/test/unit/suite.spec.js
+++ b/test/unit/suite.spec.js
@@ -4,6 +4,11 @@ var mocha = require('../../lib/mocha');
var Suite = mocha.Suite;
var Test = mocha.Test;
+function supportsFunctionNames () {
+ // eslint-disable-next-line no-extra-parens
+ return (function foo () {}).name === 'foo';
+}
+
describe('Suite', function () {
describe('.clone()', function () {
beforeEach(function () {
@@ -20,43 +25,43 @@ describe('Suite', function () {
});
it('should copy the title', function () {
- this.suite.clone().title.should.equal('To be cloned');
+ expect(this.suite.clone().title).to.equal('To be cloned');
});
it('should copy the timeout value', function () {
- this.suite.clone().timeout().should.equal(3043);
+ expect(this.suite.clone().timeout()).to.equal(3043);
});
it('should copy the slow value', function () {
- this.suite.clone().slow().should.equal(101);
+ expect(this.suite.clone().slow()).to.equal(101);
});
it('should copy the bail value', function () {
- this.suite.clone().bail().should.be.true();
+ expect(this.suite.clone().bail()).to.be(true);
});
it('should not copy the values from the suites array', function () {
- this.suite.clone().suites.should.be.empty();
+ expect(this.suite.clone().suites).to.be.empty();
});
it('should not copy the values from the tests array', function () {
- this.suite.clone().tests.should.be.empty();
+ expect(this.suite.clone().tests).to.be.empty();
});
it('should not copy the values from the _beforeEach array', function () {
- this.suite.clone()._beforeEach.should.be.empty();
+ expect(this.suite.clone()._beforeEach).to.be.empty();
});
it('should not copy the values from the _beforeAll array', function () {
- this.suite.clone()._beforeAll.should.be.empty();
+ expect(this.suite.clone()._beforeAll).to.be.empty();
});
it('should not copy the values from the _afterEach array', function () {
- this.suite.clone()._afterEach.should.be.empty();
+ expect(this.suite.clone()._afterEach).to.be.empty();
});
it('should not copy the values from the _afterAll array', function () {
- this.suite.clone()._afterAll.should.be.empty();
+ expect(this.suite.clone()._afterAll).to.be.empty();
});
});
@@ -67,14 +72,14 @@ describe('Suite', function () {
describe('when no argument is passed', function () {
it('should return the timeout value', function () {
- this.suite.timeout().should.equal(2000);
+ expect(this.suite.timeout()).to.equal(2000);
});
});
describe('when argument is passed', function () {
it('should return the Suite object', function () {
var newSuite = this.suite.timeout(5000);
- newSuite.timeout().should.equal(5000);
+ expect(newSuite.timeout()).to.equal(5000);
});
});
});
@@ -87,20 +92,20 @@ describe('Suite', function () {
describe('when given a string', function () {
it('should parse it', function () {
this.suite.slow('5 seconds');
- this.suite.slow().should.equal(5000);
+ expect(this.suite.slow()).to.equal(5000);
});
});
describe('when no argument is passed', function () {
it('should return the slow value', function () {
- this.suite.slow().should.equal(75);
+ expect(this.suite.slow()).to.equal(75);
});
});
describe('when argument is passed', function () {
it('should return the Suite object', function () {
var newSuite = this.suite.slow(5000);
- newSuite.slow().should.equal(5000);
+ expect(newSuite.slow()).to.equal(5000);
});
});
});
@@ -113,14 +118,14 @@ describe('Suite', function () {
describe('when no argument is passed', function () {
it('should return the bail value', function () {
- this.suite.bail().should.be.true();
+ expect(this.suite.bail()).to.be(true);
});
});
describe('when argument is passed', function () {
it('should return the Suite object', function () {
var newSuite = this.suite.bail(false);
- newSuite.bail().should.be.false();
+ expect(newSuite.bail()).to.be(false);
});
});
});
@@ -135,27 +140,40 @@ describe('Suite', function () {
var fn = function () {};
this.suite.beforeAll(fn);
- this.suite._beforeAll.should.have.length(1);
+ expect(this.suite._beforeAll).to.have.length(1);
var beforeAllItem = this.suite._beforeAll[0];
- beforeAllItem.title.should.match(/^"before all" hook/);
- beforeAllItem.fn.should.equal(fn);
+ expect(beforeAllItem.title).to.match(/^"before all" hook/);
+ expect(beforeAllItem.fn).to.equal(fn);
});
it('appends title to hook', function () {
- var fn = function () {};
+ var fn = function () {
+ };
this.suite.beforeAll('test', fn);
- this.suite._beforeAll.should.have.length(1);
+ expect(this.suite._beforeAll)
+ .to
+ .have
+ .length(1);
var beforeAllItem = this.suite._beforeAll[0];
- beforeAllItem.title.should.equal('"before all" hook: test');
- beforeAllItem.fn.should.equal(fn);
+ expect(beforeAllItem.title)
+ .to
+ .equal('"before all" hook: test');
+ expect(beforeAllItem.fn)
+ .to
+ .equal(fn);
+ });
+ it('uses function name if available', function () {
+ if (!supportsFunctionNames()) {
+ this.skip();
+ return;
+ }
function namedFn () {}
this.suite.beforeAll(namedFn);
- this.suite._beforeAll.should.have.length(2);
- beforeAllItem = this.suite._beforeAll[1];
- beforeAllItem.title.should.equal('"before all" hook: namedFn');
- beforeAllItem.fn.should.equal(namedFn);
+ var beforeAllItem = this.suite._beforeAll[0];
+ expect(beforeAllItem.title).to.equal('"before all" hook: namedFn');
+ expect(beforeAllItem.fn).to.equal(namedFn);
});
});
});
@@ -170,26 +188,39 @@ describe('Suite', function () {
var fn = function () {};
this.suite.afterAll(fn);
- this.suite._afterAll.should.have.length(1);
+ expect(this.suite._afterAll).to.have.length(1);
var afterAllItem = this.suite._afterAll[0];
- afterAllItem.title.should.match(/^"after all" hook/);
- afterAllItem.fn.should.equal(fn);
+ expect(afterAllItem.title).to.match(/^"after all" hook/);
+ expect(afterAllItem.fn).to.equal(fn);
});
it('appends title to hook', function () {
- var fn = function () {};
+ var fn = function () {
+ };
this.suite.afterAll('test', fn);
- this.suite._afterAll.should.have.length(1);
+ expect(this.suite._afterAll)
+ .to
+ .have
+ .length(1);
var beforeAllItem = this.suite._afterAll[0];
- beforeAllItem.title.should.equal('"after all" hook: test');
- beforeAllItem.fn.should.equal(fn);
+ expect(beforeAllItem.title)
+ .to
+ .equal('"after all" hook: test');
+ expect(beforeAllItem.fn)
+ .to
+ .equal(fn);
+ });
+ it('uses function name if available', function () {
+ if (!supportsFunctionNames()) {
+ this.skip();
+ return;
+ }
function namedFn () {}
this.suite.afterAll(namedFn);
- this.suite._afterAll.should.have.length(2);
- beforeAllItem = this.suite._afterAll[1];
- beforeAllItem.title.should.equal('"after all" hook: namedFn');
- beforeAllItem.fn.should.equal(namedFn);
+ var afterAllItem = this.suite._afterAll[0];
+ expect(afterAllItem.title).to.equal('"after all" hook: namedFn');
+ expect(afterAllItem.fn).to.equal(namedFn);
});
});
});
@@ -204,27 +235,40 @@ describe('Suite', function () {
var fn = function () {};
this.suite.beforeEach(fn);
- this.suite._beforeEach.should.have.length(1);
+ expect(this.suite._beforeEach).to.have.length(1);
var beforeEachItem = this.suite._beforeEach[0];
- beforeEachItem.title.should.match(/^"before each" hook/);
- beforeEachItem.fn.should.equal(fn);
+ expect(beforeEachItem.title).to.match(/^"before each" hook/);
+ expect(beforeEachItem.fn).to.equal(fn);
});
it('appends title to hook', function () {
- var fn = function () {};
+ var fn = function () {
+ };
this.suite.beforeEach('test', fn);
- this.suite._beforeEach.should.have.length(1);
+ expect(this.suite._beforeEach)
+ .to
+ .have
+ .length(1);
var beforeAllItem = this.suite._beforeEach[0];
- beforeAllItem.title.should.equal('"before each" hook: test');
- beforeAllItem.fn.should.equal(fn);
+ expect(beforeAllItem.title)
+ .to
+ .equal('"before each" hook: test');
+ expect(beforeAllItem.fn)
+ .to
+ .equal(fn);
+ });
+ it('uses function name if available', function () {
+ if (!supportsFunctionNames()) {
+ this.skip();
+ return;
+ }
function namedFn () {}
this.suite.beforeEach(namedFn);
- this.suite._beforeEach.should.have.length(2);
- beforeAllItem = this.suite._beforeEach[1];
- beforeAllItem.title.should.equal('"before each" hook: namedFn');
- beforeAllItem.fn.should.equal(namedFn);
+ var beforeEachItem = this.suite._beforeEach[0];
+ expect(beforeEachItem.title).to.equal('"before each" hook: namedFn');
+ expect(beforeEachItem.fn).to.equal(namedFn);
});
});
});
@@ -239,27 +283,40 @@ describe('Suite', function () {
var fn = function () {};
this.suite.afterEach(fn);
- this.suite._afterEach.should.have.length(1);
+ expect(this.suite._afterEach).to.have.length(1);
var afterEachItem = this.suite._afterEach[0];
- afterEachItem.title.should.match(/^"after each" hook/);
- afterEachItem.fn.should.equal(fn);
+ expect(afterEachItem.title).to.match(/^"after each" hook/);
+ expect(afterEachItem.fn).to.equal(fn);
});
it('appends title to hook', function () {
- var fn = function () {};
+ var fn = function () {
+ };
this.suite.afterEach('test', fn);
- this.suite._afterEach.should.have.length(1);
+ expect(this.suite._afterEach)
+ .to
+ .have
+ .length(1);
var beforeAllItem = this.suite._afterEach[0];
- beforeAllItem.title.should.equal('"after each" hook: test');
- beforeAllItem.fn.should.equal(fn);
+ expect(beforeAllItem.title)
+ .to
+ .equal('"after each" hook: test');
+ expect(beforeAllItem.fn)
+ .to
+ .equal(fn);
+ });
+ it('uses function name if available', function () {
+ if (!supportsFunctionNames()) {
+ this.skip();
+ return;
+ }
function namedFn () {}
this.suite.afterEach(namedFn);
- this.suite._afterEach.should.have.length(2);
- beforeAllItem = this.suite._afterEach[1];
- beforeAllItem.title.should.equal('"after each" hook: namedFn');
- beforeAllItem.fn.should.equal(namedFn);
+ var afterEachItem = this.suite._afterEach[0];
+ expect(afterEachItem.title).to.equal('"after each" hook: namedFn');
+ expect(afterEachItem.fn).to.equal(namedFn);
});
});
});
@@ -274,25 +331,25 @@ describe('Suite', function () {
});
it('sets the parent on the added Suite', function () {
- this.second.parent.should.equal(this.first);
+ expect(this.second.parent).to.equal(this.first);
});
it('copies the timeout value', function () {
- this.second.timeout().should.equal(4002);
+ expect(this.second.timeout()).to.equal(4002);
});
it('copies the slow value', function () {
- this.second.slow().should.equal(200);
+ expect(this.second.slow()).to.equal(200);
});
it('adds the suite to the suites collection', function () {
- this.first.suites.should.have.length(1);
- this.first.suites[0].should.equal(this.second);
+ expect(this.first.suites).to.have.length(1);
+ expect(this.first.suites[0]).to.equal(this.second);
});
it('treats suite as pending if its parent is pending', function () {
this.first.pending = true;
- this.second.isPending.should.be.true;
+ expect(this.second.isPending()).to.be(true);
});
});
@@ -325,7 +382,7 @@ describe('Suite', function () {
describe('when there is no parent', function () {
it('returns the suite title', function () {
- this.suite.fullTitle().should.equal('A Suite');
+ expect(this.suite.fullTitle()).to.equal('A Suite');
});
});
@@ -333,7 +390,7 @@ describe('Suite', 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');
+ expect(this.suite.fullTitle()).to.equal('I am a parent A Suite');
});
});
});
@@ -345,7 +402,7 @@ describe('Suite', function () {
describe('when there are no nested suites or tests', function () {
it('should return 0', function () {
- this.suite.total().should.equal(0);
+ expect(this.suite.total()).to.equal(0);
});
});
@@ -353,7 +410,7 @@ describe('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);
+ expect(this.suite.total()).to.equal(2);
});
});
});
@@ -368,7 +425,7 @@ describe('Suite', function () {
var n = 0;
function fn () { n++; }
this.suite.eachTest(fn);
- n.should.equal(0);
+ expect(n).to.equal(0);
});
});
@@ -380,7 +437,7 @@ describe('Suite', function () {
var n = 0;
function fn () { n++; }
this.suite.eachTest(fn);
- n.should.equal(2);
+ expect(n).to.equal(2);
});
});
@@ -394,7 +451,7 @@ describe('Suite', function () {
var n = 0;
function fn () { n++; }
this.suite.eachTest(fn);
- n.should.equal(2);
+ expect(n).to.equal(2);
});
});
});
@@ -402,19 +459,19 @@ describe('Suite', function () {
describe('initialization', function () {
/* eslint no-new: off */
it('should throw an error if the title isn\'t a string', function () {
- (function () {
+ expect(function () {
new Suite(undefined, 'root');
- }).should.throw();
+ }).to.throwError();
- (function () {
+ expect(function () {
new Suite(function () {}, 'root');
- }).should.throw();
+ }).to.throwError();
});
it('should not throw if the title is a string', function () {
- (function () {
+ expect(function () {
new Suite('Bdd suite', 'root');
- }).should.not.throw();
+ }).to.not.throwError();
});
});
});
@@ -422,19 +479,19 @@ describe('Suite', function () {
describe('Test', function () {
describe('initialization', function () {
it('should throw an error if the title isn\'t a string', function () {
- (function () {
+ expect(function () {
new Test(function () {});
- }).should.throw();
+ }).to.throwError();
- (function () {
+ expect(function () {
new Test(undefined, function () {});
- }).should.throw();
+ }).to.throwError();
});
it('should not throw if the title is a string', function () {
- (function () {
+ expect(function () {
new Test('test-case', function () {});
- }).should.not.throw();
+ }).to.not.throwError();
});
});
});
diff --git a/test/unit/test.spec.js b/test/unit/test.spec.js
index 455cfe04..86aa5eff 100644
--- a/test/unit/test.spec.js
+++ b/test/unit/test.spec.js
@@ -1,7 +1,6 @@
'use strict';
var mocha = require('../../lib/mocha');
-var should = require('should');
var Test = mocha.Test;
describe('Test', function () {
@@ -19,39 +18,39 @@ describe('Test', function () {
});
it('should copy the title', function () {
- this._test.clone().title.should.equal('To be cloned');
+ expect(this._test.clone().title).to.equal('To be cloned');
});
it('should copy the timeout value', function () {
- this._test.clone().timeout().should.equal(3043);
+ expect(this._test.clone().timeout()).to.equal(3043);
});
it('should copy the slow value', function () {
- this._test.clone().slow().should.equal(101);
+ expect(this._test.clone().slow()).to.equal(101);
});
it('should copy the enableTimeouts value', function () {
- this._test.clone().enableTimeouts().should.be.true();
+ expect(this._test.clone().enableTimeouts()).to.be(true);
});
it('should copy the retries value', function () {
- this._test.clone().retries().should.equal(3);
+ expect(this._test.clone().retries()).to.equal(3);
});
it('should copy the currentRetry value', function () {
- this._test.clone().currentRetry().should.equal(1);
+ expect(this._test.clone().currentRetry()).to.equal(1);
});
it('should copy the globals value', function () {
- this._test.clone().globals().should.not.be.empty();
+ expect(this._test.clone().globals()).to.not.be.empty();
});
it('should copy the parent value', function () {
- this._test.clone().parent.should.equal('foo');
+ expect(this._test.clone().parent).to.equal('foo');
});
it('should copy the file value', function () {
- this._test.clone().file.should.equal('bar');
+ expect(this._test.clone().file).to.equal('bar');
});
});
@@ -61,17 +60,17 @@ describe('Test', function () {
});
it('should not be pending by default', function () {
- should(this._test.isPending()).not.be.ok();
+ expect(this._test.isPending()).to.not.be(true);
});
it('should be pending when marked as such', function () {
this._test.pending = true;
- should(this._test.isPending()).be.ok();
+ expect(this._test.isPending()).to.be(true);
});
it('should be pending when its parent is pending', function () {
this._test.parent = { isPending: function () { return true; } };
- should(this._test.isPending()).be.ok();
+ expect(this._test.isPending()).to.be(true);
});
});
});
diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.js
index 85b19507..ad64fd84 100644
--- a/test/unit/utils.spec.js
+++ b/test/unit/utils.spec.js
@@ -7,67 +7,67 @@ var JSON = require('json3');
describe('lib/utils', function () {
describe('clean', function () {
it('should remove the wrapping function declaration', function () {
- utils.clean('function (one, two, three) {\n//code\n}')
- .should
+ expect(utils.clean('function (one, two, three) {\n//code\n}'))
+ .to
.equal('//code');
});
it('should handle newlines in the function declaration', function () {
- utils.clean('function (one, two, three)\n {\n//code\n}')
- .should
+ expect(utils.clean('function (one, two, three)\n {\n//code\n}'))
+ .to
.equal('//code');
});
it('should remove space character indentation from the function body',
function () {
- utils.clean(' //line1\n //line2')
- .should
+ expect(utils.clean(' //line1\n //line2'))
+ .to
.equal('//line1\n //line2');
});
it('should remove tab character indentation from the function body',
function () {
- utils.clean('\t//line1\n\t\t//line2')
- .should
+ expect(utils.clean('\t//line1\n\t\t//line2'))
+ .to
.equal('//line1\n\t//line2');
});
it('should handle functions with tabs in their declarations', function () {
- utils.clean('function\t(\t)\t{\n//code\n}')
- .should
+ expect(utils.clean('function\t(\t)\t{\n//code\n}'))
+ .to
.equal('//code');
});
it('should handle named functions without space after name', function () {
- utils.clean('function withName() {\n//code\n}')
- .should
+ expect(utils.clean('function withName() {\n//code\n}'))
+ .to
.equal('//code');
});
it('should handle named functions with space after name', function () {
- utils.clean('function withName () {\n//code\n}')
- .should
+ expect(utils.clean('function withName () {\n//code\n}'))
+ .to
.equal('//code');
});
it(
'should handle functions with no space between the end and the closing brace',
function () {
- utils.clean('function() {/*code*/}')
- .should
+ expect(utils.clean('function() {/*code*/}'))
+ .to
.equal('/*code*/');
});
it('should handle functions with parentheses in the same line',
function () {
- utils.clean('function() { if (true) { /* code */ } }')
- .should
+ expect(utils.clean('function() { if (true) { /* code */ } }'))
+ .to
.equal('if (true) { /* code */ }');
});
it('should handle empty functions', function () {
- utils.clean('function() {}')
- .should
+ expect(utils.clean('function() {}'))
+ .to
.equal('');
});
@@ -498,11 +498,11 @@ describe('lib/utils', function () {
describe('isBuffer()', function () {
var isBuffer = utils.isBuffer;
it('should test if object is a Buffer', function () {
- isBuffer(new Buffer([0x01]))
- .should
+ expect(isBuffer(new Buffer([0x01])))
+ .to
.equal(true);
- isBuffer({})
- .should
+ expect(isBuffer({}))
+ .to
.equal(false);
});
});
@@ -510,13 +510,18 @@ describe('lib/utils', function () {
describe('map()', function () {
var map = utils.map;
it('should behave same as Array.prototype.map', function () {
+ if (!Array.prototype.map) {
+ this.skip();
+ return;
+ }
+
var arr = [
1,
2,
3
];
- map(arr, JSON.stringify)
- .should
+ expect(map(arr, JSON.stringify))
+ .to
.eql(arr.map(JSON.stringify));
});
@@ -528,8 +533,8 @@ describe('lib/utils', function () {
2,
3
], function (e, i, arr) {
- e.should.equal(arr[index]);
- i.should.equal(index++);
+ expect(e).to.equal(arr[index]);
+ expect(i).to.equal(index++);
});
});
@@ -540,7 +545,7 @@ describe('lib/utils', function () {
'b',
'c'
], function () {
- this.should.equal(scope);
+ expect(this).to.equal(scope);
}, scope);
});
});
@@ -558,7 +563,7 @@ describe('lib/utils', function () {
], function (e) {
return e === 'b';
});
- result.should.eql(true);
+ expect(result).to.eql(true);
});
it(
@@ -571,23 +576,23 @@ describe('lib/utils', function () {
], function (e) {
return e === 'd';
});
- result.should.eql(false);
+ expect(result).to.eql(false);
});
});
describe('parseQuery()', function () {
var parseQuery = utils.parseQuery;
it('should get queryString and return key-value object', function () {
- parseQuery('?foo=1&bar=2&baz=3')
- .should
+ expect(parseQuery('?foo=1&bar=2&baz=3'))
+ .to
.eql({
foo: '1',
bar: '2',
baz: '3'
});
- parseQuery('?r1=^@(?!.*\\)$)&r2=m{2}&r3=^co.*')
- .should
+ expect(parseQuery('?r1=^@(?!.*\\)$)&r2=m{2}&r3=^co.*'))
+ .to
.eql({
r1: '^@(?!.*\\)$)',
r2: 'm{2}',
@@ -596,27 +601,27 @@ describe('lib/utils', function () {
});
it('should parse "+" as a space', function () {
- parseQuery('?grep=foo+bar')
- .should
+ expect(parseQuery('?grep=foo+bar'))
+ .to
.eql({grep: 'foo bar'});
});
});
describe('isPromise', function () {
it('should return true if the value is Promise-ish', function () {
- utils.isPromise({
+ expect(utils.isPromise({
then: function () {
}
- }).should.be.true;
+ })).to.be(true);
});
it('should return false if the value is not an object', function () {
- utils.isPromise(1).should.be.false;
+ expect(utils.isPromise(1)).to.be(false);
});
it('should return false if the value is an object w/o a "then" function',
function () {
- utils.isPromise({}).should.be.false;
+ expect(utils.isPromise({})).to.be(false);
});
});
});