forked from FormidableLabs/radium
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyle-component-test.js
149 lines (134 loc) · 3.07 KB
/
style-component-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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* eslint-disable react/prop-types */
import {Style} from 'index';
import React from 'react';
import {expectCSS, getElement, renderFcIntoDocument} from 'test-helpers';
const MSIE9_USER_AGENT =
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)';
describe('<Style> component', () => {
it("adds px suffix to properties that don't accept unitless values", () => {
const output = renderFcIntoDocument(<Style rules={{div: {height: 10}}} />);
const style = getElement(output, 'style');
expectCSS(
style,
`
div {
height: 10px;
}
`
);
});
it("doesn't add px suffix to properties that accept unitless values", () => {
const output = renderFcIntoDocument(<Style rules={{div: {zIndex: 10}}} />);
const style = getElement(output, 'style');
expectCSS(
style,
`
div {
z-index: 10;
}
`
);
});
it('can be configured standalone', () => {
const output = renderFcIntoDocument(
<Style
radiumConfig={{userAgent: MSIE9_USER_AGENT}}
rules={{div: {transform: 'rotate(90)'}}}
/>
);
const style = getElement(output, 'style');
expectCSS(
style,
`
div {
-ms-transform: rotate(90);
}
`
);
});
it('add all the prefixes when we ask for', () => {
const output = renderFcIntoDocument(
<Style
radiumConfig={{userAgent: 'all'}}
rules={{div: {transform: 'rotate(90)'}}}
/>
);
const style = getElement(output, 'style');
expectCSS(
style,
`
div{
-webkit-transform:rotate(90);
-ms-transform:rotate(90);
transform:rotate(90);
}
`
);
});
it('adds scopeSelector to each selector', () => {
const output = renderFcIntoDocument(
<Style
rules={{
div: {color: 'red'},
span: {color: 'blue'}
}}
scopeSelector=".scope"
/>
);
const style = getElement(output, 'style');
expectCSS(
style,
`
.scope div {
color: red;
}
.scope span {
color: blue;
}
`
);
});
it('adds scopeSelector to multiple selectors in a single ruleset', () => {
const output = renderFcIntoDocument(
<Style rules={{'div, span': {color: 'red'}}} scopeSelector=".scope" />
);
const style = getElement(output, 'style');
expectCSS(
style,
`
.scope div, .scope span {
color: red;
}
`
);
});
it('adds scopeSelector if no selectors are present', () => {
const output = renderFcIntoDocument(
<Style
rules={{
color: 'red',
backgroundColor: 'white',
div: {
color: 'blue',
backgroundColor: 'black'
}
}}
scopeSelector=".scope"
/>
);
const style = getElement(output, 'style');
expectCSS(
style,
`
.scope {
color: red;
background-color: white;
}
.scope div {
color: blue;
background-color: black;
}
`
);
});
});