This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscss.js
65 lines (46 loc) · 1.56 KB
/
scss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var path = require('path');
var fs = require('fs-extra');
var JsDiff = require('diff');
var rimraf = require('rimraf');
var should = require('should');
var utils = require('../lib/utils');
var tmpDir = path.join(__dirname, '..', 'tmp');
var srcDir = path.join(__dirname, 'scss');
describe('main', function() {
beforeEach(function(done) {
rimraf(tmpDir, done);
});
it('generates expected CSS', function(done) {
utils.exec('sass', ['--sourcemap=none', '--load-path', path.join(utils.DIST, 'scss'), '--update', srcDir + ':' + tmpDir], function(err) {
if (err) {
return done(typeof Error ? err : new Error(err));
}
var files = fs.readdirSync(tmpDir);
var error;
if (!files.every(function(file) {
var tmpFile = path.join(tmpDir, file);
var tmpData = fs.readFileSync(tmpFile, 'utf8');
var expected = {
'.text-primary {\n color: #FF0000; }': true,
'.ttn-color-brand {\n color: #FF0000; }': true,
'.brand-primary {\n color: #FF0000; }': true,
'${ttn-font-path}': false
};
return Object.keys(expected).every(function(css) {
var wanted = expected[css];
if ((tmpData.indexOf(css) !== -1) !== wanted) {
error = new Error((wanted ? 'Expected: ' : 'Didn\'t expect: ') + css);
return false;
}
return true;
});
})) {
return done(error);
}
done();
});
});
afterEach(function(done) {
rimraf(tmpDir, done);
});
});