-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
test-jsx-style-property-string.js
48 lines (43 loc) · 1.62 KB
/
test-jsx-style-property-string.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
import {jsxStylePropertyString} from '#core/dom/jsx/style-property-string';
describes.sandboxed('jsxStylePropertyString', {}, () => {
it('returns empty string with nullish', () => {
expect(jsxStylePropertyString('a', null)).to.equal('');
expect(jsxStylePropertyString('b', undefined)).to.equal('');
expect(
jsxStylePropertyString('c', null, /* isDimensional */ true)
).to.equal('');
expect(
jsxStylePropertyString('d', undefined, /* isDimensional */ true)
).to.equal('');
});
it('returns empty string with empty string', () => {
expect(jsxStylePropertyString('a', '')).to.equal('');
expect(jsxStylePropertyString('b', '')).to.equal('');
expect(jsxStylePropertyString('c', '', /* isDimensional */ true)).to.equal(
''
);
expect(jsxStylePropertyString('d', '', /* isDimensional */ true)).to.equal(
''
);
});
it('returns string value', () => {
expect(jsxStylePropertyString('background', 'red')).to.equal(
'background:red;'
);
expect(
jsxStylePropertyString('background', 'red', /* isDimensional */ true)
).to.equal('background:red;');
});
it('returns non-dimensional number value as-is', () => {
expect(jsxStylePropertyString('flex', 1)).to.equal('flex:1;');
expect(jsxStylePropertyString('opacity', 0.5)).to.equal('opacity:0.5;');
});
it('returns dimensional number value with px', () => {
expect(
jsxStylePropertyString('width', 150, /* isDimensional */ true)
).to.equal('width:150px;');
expect(
jsxStylePropertyString('height', 321, /* isDimensional */ true)
).to.equal('height:321px;');
});
});