/
kss_modifier.js
67 lines (55 loc) · 2 KB
/
kss_modifier.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
66
67
/*global suite*/
var kss = require('../index.js'),
assert = require('assert'),
common = require('./common.js'),
path = require('path');
var KssModifier = kss.KssModifier,
styleDirectory = path.join(__dirname, '/fixtures-styles/');
common = common(styleDirectory);
suite('KssModifier', function() {
'use strict';
common.hasMethod(new KssModifier({}), 'name');
common.hasMethod(new KssModifier({}), 'description');
common.hasMethod(new KssModifier({}), 'className');
common.hasMethod(new KssModifier({}), 'markup');
suite('.name()', function() {
common.testAllSections('should return data.name', '*.less|*.css', function(section) {
var modifiers = section.modifiers(),
i, l = modifiers.length;
for (i = 0; i < l; i += 1) {
assert.equal(modifiers[i].data.name, modifiers[i].name());
}
});
});
suite('.description()', function() {
common.testAllSections('should return data.description', '*.less|*.css', function(section) {
var modifiers = section.modifiers(),
i, l = modifiers.length;
for (i = 0; i < l; i += 1) {
assert.equal(modifiers[i].data.description, modifiers[i].description());
}
});
});
suite('.className()', function() {
common.testAllSections('should be valid CSS classes', '*.less|*.css', function(section) {
var modifiers = section.modifiers(),
i, l = modifiers.length;
for (i = 0; i < l; i += 1) {
assert.ok(modifiers[i].className().match(/[a-z \-_]/gi));
}
});
});
suite('.markup()', function() {
common.testAllSections('should return an unfiltered data.section.markup', '*.less|*.css', function(section) {
var modifiers = section.modifiers(),
i, l = modifiers.length;
for (i = 0; i < l; i += 1) {
if (!modifiers[i].markup()) {
continue;
}
assert.equal(section.data.markup, modifiers[i].data.section.data.markup);
assert.equal(section.data.markup, modifiers[i].markup());
}
});
});
});