Skip to content

Commit 223c7af

Browse files
committed
Add chai-as-promised to reduce test boilerplate
1 parent a25c778 commit 223c7af

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"chai": "^3.4.1",
36+
"chai-as-promised": "^5.2.0",
3637
"eslint": "^1.10.3",
3738
"eslint-config-airbnb": "^5.0.0",
3839
"mocha": "^2.3.4",

test/test.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ var rewire = require('rewire');
77
var suitcss = rewire('../lib');
88
var path = require('path');
99
var sinonChai = require('sinon-chai');
10+
var chaiAsPromised = require('chai-as-promised');
1011
require('sinon-as-promised');
1112

1213
chai.use(sinonChai);
14+
chai.use(chaiAsPromised);
1315
var expect = chai.expect;
1416

1517
/**
@@ -152,19 +154,16 @@ describe('suitcss', function() {
152154
});
153155

154156
describe('stylelint', function() {
155-
it('should throw an error if stylelint fails', function(done) {
156-
suitcss('@import "./stylelint.css"', {
157-
lint: true,
158-
root: 'test/fixtures',
159-
'postcss-reporter': {
160-
throwError: true
161-
}
162-
}).then(function() {
163-
done(new Error('stylelint should have failed conformance'));
164-
}).catch(function(err) {
165-
expect(err.message).to.contain('postcss-reporter: warnings or errors were found');
166-
done();
167-
});
157+
it('should throw an error if stylelint fails', function() {
158+
return expect(
159+
suitcss('@import "./stylelint.css"', {
160+
lint: true,
161+
root: 'test/fixtures',
162+
'postcss-reporter': {
163+
throwError: true
164+
}
165+
})
166+
).to.be.rejectedWith(Error, 'postcss-reporter: warnings or errors were found');
168167
});
169168
});
170169

0 commit comments

Comments
 (0)