Skip to content

Commit fdb2a9f

Browse files
author
dkniazevych
committed
- fixed stringify tests;
- merge PR 48;
1 parent c6c4cbf commit fdb2a9f

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

gulpfile.babel.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,25 @@ gulp.task('test:all', (done) => {
123123
});
124124

125125
gulp.task('test:run', ['build:test'], () => {
126+
let mochaError = {};
127+
126128
return gulp
127129
.src(path.join(config.dirs.build, config.builds.test, '**', '*.spec.js'), {read: false})
128130
.pipe(mocha({
129131
reporter: config.test.reporter
130132
}))
131-
.on('error', function () {
133+
.on('error', function (error) {
134+
mochaError = error;
132135
// eslint-disable-next-line no-invalid-this
133136
this.emit('end');
137+
})
138+
.on('end', () => {
139+
if (mochaError.message) {
140+
throw new util.PluginError({
141+
plugin: 'gulp-mocha',
142+
message: mochaError.message
143+
});
144+
}
134145
});
135146
});
136147

test/parser/extend.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Parser', () => {
3535
expect(root.first.first.selector).to.eql('&:extend(.bucket tr)');
3636
expect(root.first.first.params).to.eql('(.bucket tr)');
3737
expect(root.first.first.extendRule).to.eql(true);
38-
expect(root.first.first.toString()).to.be.eql('&:extend(.bucket tr);');
38+
expect(root.first.first.toString()).to.be.eql('&:extend(.bucket tr)');
3939
});
4040

4141
it('parses :extend() after selector', () => {

test/stringify.spec.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import cases from 'postcss-parser-tests';
55
import {expect} from 'chai';
6-
import parse from './../lib/less-parse';
76
import postcss from 'postcss';
8-
import postcssLess from 'postcss-less';
9-
import stringify from 'postcss-less/less-stringify';
7+
import parse from './../lib/less-parse';
8+
import postcssLess from './../lib/less-syntax';
9+
import stringify from './../lib/less-stringify';
1010

1111
describe('#stringify()', () => {
1212
describe('CSS for PostCSS', () => {
@@ -60,7 +60,7 @@ describe('#stringify()', () => {
6060
syntax: postcssLess,
6161
stringifier: stringify
6262
}).then((result) => {
63-
expect(result.content).to.eql(less);
63+
expect(result.content).to.eql('.selector:extend(.f, .g) {&:extend(.a)}');
6464
done();
6565
}).catch((error) => {
6666
done(error);
@@ -103,21 +103,37 @@ describe('#stringify()', () => {
103103
width: @width;
104104
}
105105
}
106-
106+
107107
.rotation(@deg:5deg){
108108
.transform(rotate(@deg));
109109
}
110110
`;
111+
112+
function prepareOutput (str) {
113+
return str.replace(/\s{2,}/g, ' ');
114+
}
111115

112116
postcss().process(less, {
113117
syntax: postcssLess,
114118
stringifier: stringify
115119
}).then((result) => {
116-
expect(result.content).to.eql(less);
120+
expect(prepareOutput(result.content)).to.eql(prepareOutput(`
121+
.container {
122+
.mixin-1()
123+
.mixin-2
124+
.mixin-3 (@width: 100px) {
125+
width: @width;
126+
}
127+
}
128+
129+
.rotation(@deg:5deg){
130+
.transform(rotate(@deg))
131+
}
132+
`));
117133
done();
118134
}).catch((error) => {
119135
done(error);
120136
});
121137
});
122138
});
123-
});
139+
});

0 commit comments

Comments
 (0)