Skip to content

Commit fd3305b

Browse files
committed
Merge pull request #150 from kizu/integral-test-fix
Fixing the detection integral tests
2 parents 72ca2e8 + 4f8b0cc commit fd3305b

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

test/mocha.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,28 @@ mocha.suite.beforeEach(function() {
5858
* @param {Object} expected Expected config with detected options
5959
*/
6060
this.shouldDetect = function(options, input, expected) {
61+
// We need to “sort” the input and expected objects, as their order may vary
62+
function sortObject(o) {
63+
var sorted = {};
64+
var key = [];
65+
var a = [];
66+
67+
for (key in o) {
68+
if (o.hasOwnProperty(key)) {
69+
a.push(key);
70+
}
71+
}
72+
73+
a.sort();
74+
75+
for (key = 0; key < a.length; key++) {
76+
sorted[a[key]] = o[a[key]];
77+
}
78+
return sorted;
79+
}
6180
assert.equal(
62-
JSON.stringify(this.comb.detectInString(input, options)),
63-
JSON.stringify(expected)
81+
JSON.stringify(sortObject(this.comb.detectInString(input, options))),
82+
JSON.stringify(sortObject(expected))
6483
);
6584
};
6685
});

test/options/integral.js

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,12 @@ describe('integral test', function() {
1111
this.shouldBeEqual('integral.css', 'integral.expected.css');
1212
});
1313

14-
it.skip('Should detect everything in integral test', function(done) {
15-
var config = this.comb.getConfig('csscomb');
16-
var input = this.readFile('integral.css');
17-
var expected = {
18-
'remove-empty-rulesets': true,
19-
'always-semicolon': true,
20-
'color-case': 'lower',
21-
'color-shorthand': true,
22-
'element-case': 'lower',
23-
'leading-zero': false,
24-
quotes: 'single',
25-
'strip-spaces': true,
26-
'eof-newline': true,
27-
'stick-brace': '\n',
28-
'colon-space': ['', ' '],
29-
'combinator-space': [' ', ' '],
30-
'rule-indent': ' ',
31-
'block-indent': ' ',
32-
'unitless-zero': true,
33-
'vendor-prefix-align': true
34-
};
35-
14+
it('Should detect everything in integral test', function() {
15+
var input = this.readFile('integral.expected.css');
16+
// Clone the required config object, otherwise other tests would fail
17+
var expected = JSON.parse(JSON.stringify(this.comb.getConfig('csscomb')));
18+
delete expected['sort-order'];
19+
delete expected['exclude'];
3620
this.shouldDetect(undefined, input, expected);
37-
38-
expected['sort-order'] = config['sort-order'];
39-
this.comb.configure(expected);
40-
this.shouldDetect(undefined, 'integral.css', expected);
4121
});
4222
});

0 commit comments

Comments
 (0)