Skip to content

Commit

Permalink
Merge pull request #89 from Turbo87/as-promised
Browse files Browse the repository at this point in the history
Use "chai-as-promised" for testing
  • Loading branch information
Turbo87 committed Mar 31, 2017
2 parents d9bf23e + 6ac2563 commit 2bf9b21
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"broccoli-source": "^1.1.0",
"broccoli-stew": "^1.2.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"mocha": "^3.0.1",
"sinon": "^2.0.0",
"sinon-chai": "^2.8.0"
Expand Down
2 changes: 2 additions & 0 deletions test/chai.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const chai = require('chai');
const sinonChai = require('sinon-chai');
const asPromised = require('chai-as-promised');

chai.use(sinonChai);
chai.use(asPromised);

module.exports = chai;
39 changes: 15 additions & 24 deletions test/main-tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,49 +200,40 @@ describe('EslintValidationFilter', function() {
});

it('throws when `throwOnError` is set and result severity is >= 2', function() {
return shouldReportErrors(FIXTURES_PATH, {
return expect(shouldReportErrors(FIXTURES_PATH, {
options: {
ignore: false,
},
throwOnError: true
})().then(
() => { throw new Error('test should have failed'); },
(err) => {
expect(err).to.be.an('error');
expect(err.message).to.equal('rules violation with `error` severity level');
}
);
})()).to.be.rejected.then(err => {
expect(err).to.be.an('error');
expect(err.message).to.equal('rules violation with `error` severity level');
});
});

it('throws when `throwOnWarn` is set and result severity is >= 2', function() {
return shouldReportErrors(FIXTURES_PATH, {
return expect(shouldReportErrors(FIXTURES_PATH, {
options: {
ignore: false,
},
throwOnWarn: true
})().then(
() => { throw new Error('test should have failed'); },
(err) => {
expect(err).to.be.an('error');
expect(err.message).to.equal('rules violation with `error` severity level');
}
);
})()).to.be.rejected.then(err => {
expect(err).to.be.an('error');
expect(err.message).to.equal('rules violation with `error` severity level');
});
});

it('throws when `throwOnWarn` is set and result severity is 1', function() {
return shouldReportErrors(FIXTURES_PATH, {
return expect(shouldReportErrors(FIXTURES_PATH, {
options: {
ignore: true,
cache: false, // ensure that other tests
ignorePath: FIXTURES_PATH_ESLINTIGNORE_FOR_WARNING
},
throwOnWarn: true
})().then(
() => { throw new Error('test should have failed'); },
(err) => {
expect(err).to.be.an('error');
expect(err.message).to.equal('rules violation with `warn` severity level');
}
);
})()).to.be.rejected.then(err => {
expect(err).to.be.an('error');
expect(err.message).to.equal('rules violation with `warn` severity level');
});
});
});

0 comments on commit 2bf9b21

Please sign in to comment.