Skip to content

Commit

Permalink
convert test/integration/options.spec.js to unexpected
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
boneskull committed Apr 21, 2018
1 parent ada86aa commit eb6bcff
Showing 1 changed file with 69 additions and 119 deletions.
188 changes: 69 additions & 119 deletions test/integration/options.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var path = require('path');
var assert = require('assert');
var helpers = require('./helpers');
var run = helpers.runMochaJSON;
var directInvoke = helpers.invokeMocha;
Expand All @@ -20,12 +19,7 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 1);

assert.equal(res.failures[0].title, 'throws an error');
assert.equal(res.code, 1);
expect(res, 'to have failed');
done();
});
});
Expand All @@ -36,12 +30,7 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);

assert.equal(res.passes[0].title, 'should pass');
assert.equal(res.code, 0);
expect(res, 'to have passed');
done();
});
});
Expand All @@ -58,13 +47,11 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 1);

assert.equal(res.passes[0].title, 'should display this spec');
assert.equal(res.failures[0].title, 'should only display this error');
assert.equal(res.code, 1);
expect(res, 'to have failed')
.and('to have passed test', 'should display this spec')
.and('to have failed test', 'should only display this error')
.and('to have passed test count', 1);
done();
});
});
Expand All @@ -75,12 +62,8 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 1);

assert.equal(res.failures[0].title, 'should only display this error');
assert.equal(res.code, 1);
expect(res, 'to have failed')
.and('to have run test', 'should only display this error');
done();
});
});
Expand All @@ -97,13 +80,8 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);

assert.equal(res.passes[0].fullTitle,
'alpha should be executed first');
assert.equal(res.code, 0);
expect(res, 'to have passed test count', 2)
.and('to have passed test order', 'should be executed first');
done();
});
});
Expand All @@ -118,13 +96,9 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);

assert.equal(res.passes[0].fullTitle,
'alpha should be executed first');
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 2)
.and('to have passed test order', 'should be executed first');
done();
});
});
Expand All @@ -140,17 +114,14 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 3);
assert.equal(res.stats.failures, 0);

assert.equal(res.passes[0].fullTitle,
'alpha should be executed first');
assert.equal(res.passes[1].fullTitle,
'beta should be executed second');
assert.equal(res.passes[2].fullTitle,
'theta should be executed third');
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 3)
.and(
'to have passed test order',
'should be executed first',
'should be executed second',
'should be executed third'
);
done();
});
});
Expand All @@ -167,13 +138,8 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);

assert.equal(res.passes[0].title,
'should have no effect if attempted twice in the same suite');
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 1);
done();
});
});
Expand All @@ -184,15 +150,13 @@ describe('options', function () {
done(err);
return;
}

assert.equal(res.stats.tests, 2);
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);

assert.equal(res.passes[0].title, 'should run this');
assert.equal(res.passes[1].title, 'should run this, too');
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 2)
.and(
'to have passed test order',
'should run this',
'should run this, too'
);
done();
});
});
Expand All @@ -203,13 +167,8 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 1);

assert.equal(res.failures[0].title,
'Uncaught error outside test suite');
assert.equal(res.code, 1);
expect(res, 'to have failed')
.and('to have failed test', 'Uncaught error outside test suite');
done();
});
});
Expand All @@ -223,10 +182,9 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 2)
.and('not to have pending tests');
done();
});
});
Expand All @@ -239,10 +197,9 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 4);
assert.equal(res.stats.failures, 0);
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 4)
.and('not to have pending tests');
done();
});
});
Expand All @@ -254,10 +211,10 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 4);
assert.equal(res.stats.failures, 1);
assert.equal(res.code, 1);
expect(res, 'to have failed')
.and('to have passed test count', 4)
.and('to have failed test count', 1)
.and('not to have pending tests');
done();
});
});
Expand All @@ -271,10 +228,9 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 4);
assert.equal(res.stats.failures, 0);
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have passed test count', 4)
.and('not to have pending tests');
done();
});
});
Expand All @@ -289,12 +245,10 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.tests, 1);
assert.equal(res.tests[0].currentRetry, 3);
assert.equal(res.stats.failures, 1);
assert.equal(res.code, 1);
expect(res, 'to have failed')
.and('not to have pending tests')
.and('not to have passed tests')
.and('to have retried test', 'should fail', 3);
done();
});
});
Expand All @@ -313,7 +267,7 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.code, 0);
expect(res, 'to have passed');
done();
});
});
Expand All @@ -324,17 +278,18 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.code, 1);
assert.equal(res.failures[0].err.message, onlyErrorMessage);
expect(res, 'to have failed with error', onlyErrorMessage);
done();
});
});

it('fails if there are tests in suites marked only', function (done) {
run('options/forbid-only/only-suite.js', args, function (err, res) {
assert(!err);
assert.equal(res.code, 1);
assert.equal(res.failures[0].err.message, onlyErrorMessage);
if (err) {
done(err);
return;
}
expect(res, 'to have failed with error', onlyErrorMessage);
done();
});
});
Expand All @@ -353,7 +308,7 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.code, 0);
expect(res, 'to have passed');
done();
});
});
Expand All @@ -376,8 +331,7 @@ describe('options', function () {
done(err);
return;
}
assert.equal(res.code, 1);
assert.equal(res.failures[0].err.message, pendingErrorMessage);
expect(res, 'to have failed with error', pendingErrorMessage);
done();
});
});
Expand Down Expand Up @@ -412,7 +366,7 @@ describe('options', function () {
done(err);
return;
}
expect(didExit).to.equal(shouldExit);
expect(didExit, 'to be', shouldExit);
done();
});

Expand Down Expand Up @@ -445,7 +399,7 @@ describe('options', function () {
if (error) {
return done(error);
}
expect(result.output).to.contain('Usage:');
expect(result.output, 'to contain', 'Usage:');
done();
}, path.join(__dirname, 'fixtures', 'options', 'help'));
});
Expand All @@ -472,20 +426,17 @@ describe('options', function () {
'--exclude',
'test/integration/fixtures/options/exclude/fail.fixture.js'
], function (res) {
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);
assert.equal(res.passes[0].title, 'should find this test');
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('to have run test', 'should find this test')
.and('not to have pending tests');
}, done);
});

it('should exclude globbed files', function (done) {
runMochaTest('options/exclude/**/*.fixture.js', ['--exclude', '**/fail.fixture.js'], function (res) {
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('not to have pending tests')
.and('to have passed test count', 2);
}, done);
});

Expand All @@ -496,10 +447,9 @@ describe('options', function () {
'--exclude',
'test/integration/fixtures/options/exclude/nested/fail.fixture.js'
], function (res) {
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);
assert.equal(res.code, 0);
expect(res, 'to have passed')
.and('not to have pending tests')
.and('to have passed test count', 2);
}, done);
});
});
Expand Down

0 comments on commit eb6bcff

Please sign in to comment.