-
Notifications
You must be signed in to change notification settings - Fork 324
/
find-component-in-test.js
93 lines (84 loc) · 2.79 KB
/
find-component-in-test.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var assert = require('assert');
var vows = require('vows');
var wrapForOptimizing = require('../../../../lib/optimizer/wrap-for-optimizing').all;
var compatibility = require('../../../../lib/utils/compatibility');
var populateComponents = require('../../../../lib/optimizer/level-2/properties/populate-components');
var validator = require('../../../../lib/optimizer/validator');
var findComponentIn = require('../../../../lib/optimizer/level-2/properties/find-component-in');
vows.describe(findComponentIn)
.addBatch({
'missing': {
'topic': function () {
var shorthand = wrapForOptimizing([
[
'property',
['property-name', 'margin'],
['property-value', '0px']
]
])[0];
var longhand = wrapForOptimizing([
[
'property',
['property-name', 'padding-top'],
['property-value', '0px']
]
])[0];
populateComponents([shorthand], validator(compatibility({})), []);
return [shorthand, longhand];
},
'is null': function (topic) {
assert.isUndefined(findComponentIn.apply(null, topic));
}
},
'present': {
'topic': function () {
var shorthand = wrapForOptimizing([
[
'property',
['property-name', 'margin'],
['property-value', '0px']
]
])[0];
var longhand = wrapForOptimizing([
[
'property',
['property-name', 'margin-top'],
['property-value', '1px']
]
])[0];
populateComponents([shorthand], validator(compatibility({})), []);
return [shorthand, longhand];
},
'is null': function (topic) {
assert.equal(findComponentIn.apply(null, topic).name, 'margin-top');
assert.deepEqual(findComponentIn.apply(null, topic).value, [['property-value', '0px']]);
}
},
'subcomponent': {
'topic': function () {
var shorthand = wrapForOptimizing([
[
'property',
['property-name', 'border'],
['property-value', '1px'],
['property-value', 'solid'],
['property-value', 'red']
]
])[0];
var longhand = wrapForOptimizing([
[
'property',
['property-name', 'border-left-style'],
['property-value', 'dotted']
]
])[0];
populateComponents([shorthand], validator(compatibility({})), []);
return [shorthand, longhand];
},
'is null': function (topic) {
assert.equal(findComponentIn.apply(null, topic).name, 'border-left-style');
assert.deepEqual(findComponentIn.apply(null, topic).value, [['property-value', 'solid']]);
}
}
})
.export(module);