Skip to content

Commit fee2426

Browse files
committed
Use Jest
1 parent a62c33c commit fee2426

15 files changed

+1034
-203
lines changed

.eslintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ yarn.lock
1010
build/
1111
test/
1212
.travis.yml
13-
.eslintrc
1413

1514
gulpfile.js

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ BUILD_CONFIGS.forEach(function (config) {
3737
gulp.task('build', BUILD_CONFIGS);
3838

3939
gulp.task('test', ['build'], function () {
40-
var mocha = require('gulp-mocha');
41-
return gulp.src('build/*.js', { read: false }).pipe(mocha());
40+
var jest = require('gulp-jest').default;
41+
return gulp.src('build').pipe(jest());
4242
});
4343

4444
gulp.task('default', ['lint', 'test']);

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"postcss-load-config": "^1.0.0"
2424
},
2525
"devDependencies": {
26-
"chai": "^3.5.0",
26+
"eslint": "^3.11.1",
2727
"eslint-config-postcss": "^2.0.2",
2828
"fs-extra": "^1.0.0",
2929
"gulp": "^3.9.1",
3030
"gulp-eslint": "^3.0.1",
31-
"gulp-mocha": "^3.0.1",
31+
"gulp-jest": "^0.6.0",
3232
"json-loader": "^0.5.4",
3333
"lint-staged": "^3.2.1",
3434
"postcss-js": "^0.1.3",
@@ -42,6 +42,12 @@
4242
"lint-staged": "lint-staged",
4343
"test": "gulp"
4444
},
45+
"eslintConfig": {
46+
"extends": "eslint-config-postcss/es5",
47+
"env": {
48+
"jest": true
49+
}
50+
},
4551
"lint-staged": {
4652
"*.js": "eslint"
4753
},

test/test-custom-parser.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
var expect = require('chai').expect;
2-
31
describe('custom parser', function () {
42

53
it('processes sugarss', function () {
64
var css = require('!raw-loader!../!' +
75
'./cases/sugar.css');
8-
expect(css).to.eql('a\n color: rgba(255, 0, 0, 0.1)\n');
6+
expect(css).toEqual('a\n color: rgba(255, 0, 0, 0.1)\n');
97
});
108

119
});

test/test-default.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,58 @@
1-
var expect = require('chai').expect;
2-
31
describe('default', function () {
42

53
it('processes CSS with default plugins', function () {
64
var css = require('!raw-loader!../!./cases/style.css');
7-
expect(css).to.eql('a { color: blue }\n');
5+
expect(css).toEqual('a { color: blue }\n');
86
});
97

108
it('overrides default config by subdir config', function () {
119
var css = require('!raw-loader!../!./cases/config/style.css');
12-
expect(css).to.eql('a { color: black }\n');
10+
expect(css).toEqual('a { color: black }\n');
1311
});
1412

1513
it('send webpack instance to config', function () {
1614
var css = require('!raw-loader!../!./cases/env/style.css');
17-
expect(css).to.eql('a::before { content: "style.css" }\n');
15+
expect(css).toEqual('a::before { content: "style.css" }\n');
1816
});
1917

2018
it('processes CSS in safe mode', function () {
2119
var css = require('!raw-loader' +
2220
'!../?parser=postcss-safe-parser' +
2321
'!./cases/broken.css');
24-
expect(css).to.eql('a { color:\n}');
22+
expect(css).toEqual('a { color:\n}');
2523
});
2624

2725
it('lets other plugins alter the used plugins', function () {
2826
var css = require('!raw-loader!../?rewrite=true' +
2927
'!./cases/style.css');
30-
expect(css).to.eql('a { color: black }\n');
28+
expect(css).toEqual('a { color: black }\n');
3129
});
3230

3331
it('processes CSS-in-JS', function () {
3432
var css = require('!raw-loader' +
3533
'!../?parser=postcss-js' +
3634
'!./cases/style.js');
37-
expect(css).to.eql('a {\n color: blue\n}');
35+
expect(css).toEqual('a {\n color: blue\n}');
3836
});
3937

4038
it('processes CSS with exec', function () {
4139
var css = require('!raw-loader' +
4240
'!../?exec' +
4341
'!./cases/exec.js');
44-
expect(css).to.eql('a {\n color: green\n}');
42+
expect(css).toEqual('a {\n color: green\n}');
4543
});
4644

4745
it('inlines map', function () {
4846
var css = require('!raw-loader!../?sourceMap=inline' +
4947
'!./cases/style.css');
50-
expect(css).to.include('/*# sourceMappingURL=');
48+
expect(css).toContain('/*# sourceMappingURL=');
5149
});
5250

5351
it('allows to change config path', function () {
5452
var css = require('!raw-loader' +
5553
'!../?config=test/cases/config/postcss.config.js' +
5654
'!./cases/style.css');
57-
expect(css).to.eql('a { color: black }\n');
55+
expect(css).toEqual('a { color: black }\n');
5856
});
5957

6058
});

test/test-explicit-plugins.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
var expect = require('chai').expect;
2-
31
describe('explicit plugins', function () {
42

53
it('processes CSS with custom plugins', function () {
64
var css = require('!raw-loader!../!' +
75
'./cases/style.css');
8-
expect(css).to.eql('a { color: rgba(255, 0, 0, 0.1) }\n');
6+
expect(css).toEqual('a { color: rgba(255, 0, 0, 0.1) }\n');
97
});
108

119
});

test/test-incorrect-using-packs.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var expect = require('chai').expect;
2-
31
describe('incorrect using packs', function () {
42

53
it('fails to load specific pack', function () {
@@ -10,7 +8,7 @@ describe('incorrect using packs', function () {
108
} catch (err) {
119
error = err;
1210
}
13-
expect(error.message).to.match(/find module/);
11+
expect(error.message).toMatch(/find module/);
1412
});
1513

1614
});

test/test-with-packs.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
var expect = require('chai').expect;
2-
31
describe('with packs', function () {
42

53
it('processes CSS with default plugins', function () {
64
var css = require('!raw-loader!../!' +
75
'./cases/style.css');
8-
expect(css).to.eql('a { color: rgba(255, 0, 0, 0.1) }\n');
6+
expect(css).toEqual('a { color: rgba(255, 0, 0, 0.1) }\n');
97
});
108

119
it('processes CSS with custom plugins', function () {
1210
var css = require('!raw-loader!../?pack=blues!' +
1311
'./cases/style.css');
14-
expect(css).to.eql('a { color: blue }\n');
12+
expect(css).toEqual('a { color: blue }\n');
1513
});
1614

1715
});

test/webpack-custom-parser.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
context: __dirname,
1111
entry: './test-custom-parser.js',
1212
output: {
13+
filename: 'test-custom-parser.test.js',
1314
path: path.join(__dirname, '..', 'build')
1415
},
1516
postcss: function () {

test/webpack-default.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
context: __dirname,
88
entry: './test-default.js',
99
output: {
10+
filename: 'test-default.test.js',
1011
path: path.join(__dirname, '..', 'build')
1112
},
1213
plugins: [

test/webpack-explicit-plugins.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
context: __dirname,
1010
entry: './test-explicit-plugins.js',
1111
output: {
12+
filename: 'test-explicit-plugins.test.js',
1213
path: path.join(__dirname, '..', 'build')
1314
},
1415
postcss: function () {

test/webpack-incorrect-using-packs.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
context: __dirname,
88
entry: './test-incorrect-using-packs.js',
99
output: {
10+
filename: 'test-incorrect-using-packs.test.js',
1011
path: path.join(__dirname, '..', 'build')
1112
},
1213
plugins: [

test/webpack-with-packs.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
context: __dirname,
1010
entry: './test-with-packs.js',
1111
output: {
12+
filename: 'test-with-packs.test.js',
1213
path: path.join(__dirname, '..', 'build')
1314
},
1415
postcss: function () {

0 commit comments

Comments
 (0)