Skip to content

Commit 8db5a6b

Browse files
Create tests for the attributes to props helper
Check that the style attribute works as expected.
1 parent 24cce18 commit 8db5a6b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/attributes-to-props.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var assert = require('assert');
7+
var attributesToProps = require('../lib/attributes-to-props');
8+
9+
/**
10+
* Tests for attributes to props helper.
11+
*/
12+
describe('attributes to props helper', function() {
13+
14+
it('converts CSS style string to JS style object', function() {
15+
// proper css
16+
assert.deepEqual(
17+
attributesToProps({
18+
style: 'color: #f00; font-size: 42px; z-index: -1;'
19+
}),
20+
{
21+
style: {
22+
color: '#f00',
23+
fontSize: '42px',
24+
zIndex: '-1'
25+
}
26+
}
27+
);
28+
29+
// valid but messy
30+
assert.deepEqual(
31+
attributesToProps({
32+
style: 'border-bottom-left-radius:1em;border-right-style:solid;Z-Index:-1'
33+
}),
34+
{
35+
style: {
36+
borderBottomLeftRadius: '1em',
37+
borderRightStyle: 'solid',
38+
zIndex: '-1'
39+
}
40+
}
41+
);
42+
});
43+
44+
});

0 commit comments

Comments
 (0)