-
Notifications
You must be signed in to change notification settings - Fork 324
/
advanced-test.js
105 lines (104 loc) · 3.06 KB
/
advanced-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
94
95
96
97
98
99
100
101
102
103
104
105
var vows = require('vows');
var optimizerContext = require('../test-helper').optimizerContext;
vows.describe('advanced optimizer')
.addBatch(
optimizerContext('all optimizations', {
'adjacent': [
'a{display:none}a{display:none;visibility:hidden}',
'a{display:none;visibility:hidden}'
],
'overriding by !important': [
'a{margin:0}a{margin:0!important}',
'a{margin:0!important}'
],
'shorthands and no space after closing brace': [
'.a{background:rgba(0,0,0,0)url(//example.com/a.jpg)}',
'.a{background:url(//example.com/a.jpg) rgba(0,0,0,0)}'
]
}, { advanced: true })
)
.addBatch(
optimizerContext('advanced on & aggressive merging on', {
'repeated' : [
'a{color:red;color:red}',
'a{color:red}'
]
}, { advanced: true, aggressiveMerging: true })
)
.addBatch(
optimizerContext('advanced on & aggressive merging on - IE8 mode', {
'units': [
'.one{width:1px;width:1rem;display:block}.two{color:red}.one{width:2px;width:1.1rem}',
'.one{display:block;width:2px;width:1.1rem}.two{color:red}'
]
}, { advanced: true, aggressiveMerging: true, compatibility: 'ie8' })
)
.addBatch(
optimizerContext('advanced on & aggressive merging off', {
'repeated' : [
'a{color:red;color:red}',
'a{color:red}'
]
}, { advanced: true, aggressiveMerging: false })
)
.addBatch(
optimizerContext('advanced off', {
'repeated' : [
'a{color:red;color:red}',
'a{color:red;color:red}'
]
}, { advanced: false })
)
.addBatch(
optimizerContext('@media', {
'empty': [
'@media (min-width:980px){}',
''
],
'whitespace': [
' @media ( min-width: 980px ){}',
''
],
'body': [
'@media (min-width:980px){\na\n{color:red}}',
'@media (min-width:980px){a{color:red}}'
],
'multiple': [
'@media screen, print, (min-width:980px){a{color:red}}',
'@media screen,print,(min-width:980px){a{color:red}}'
],
'nested once': [
'@media screen { @media print { a{color:red} } }',
'@media screen{@media print{a{color:red}}}'
],
'nested twice': [
'@media screen { @media print { @media (min-width:980px) { a{color:red} } } }',
'@media screen{@media print{@media (min-width:980px){a{color:red}}}}'
]
})
)
.addBatch(
optimizerContext('@font-face', {
'rebuilding': [
'@font-face{font-family:PublicVintage;src:url(/PublicVintage.otf) format(\'opentype\')}',
'@font-face{font-family:PublicVintage;src:url(/PublicVintage.otf) format(\'opentype\')}'
]
})
)
.addBatch(
optimizerContext('unit compacting', {
'font-size': [
'div{font-size:1rem;font-size:16px}',
'div{font-size:16px}'
],
'height': [
'div{height:1rem;height:16px}',
'div{height:16px}'
],
'width': [
'div{width:1rem;width:16px}',
'div{width:16px}'
]
})
)
.export(module);