Skip to content

Commit a08f521

Browse files
test(index): add more misc and one-off test cases
1 parent c2c774c commit a08f521

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

test/data.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const cases = [
55
'margin: 0 auto;',
66
'border: 5px solid #BADA55;',
77
'font-size: .75em; position:absolute;width: 33.3%; z-index:1337;',
8+
'font-family: "Goudy Bookletter 1911", Gill Sans Extrabold, sans-serif;',
89

910
// multiple of same property
1011
'color:rgba(0,0,0,1);color:white;',
@@ -41,7 +42,11 @@ const cases = [
4142

4243
// custom
4344
'foo: bar;',
44-
'foo:bar; baz:qux'
45+
'foo:bar; baz:qux',
46+
47+
// misc
48+
'',
49+
'overflow:'
4550
];
4651

4752
const snapshots = [

test/index.spec.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const css = require('css');
1+
const cssParse = require('css/lib/parse');
22
const inlineStyleParser = require('..');
33
const { cases, snapshots } = require('./data');
44

@@ -9,7 +9,7 @@ const { cases, snapshots } = require('./data');
99
function getDeclarations(inlineStyle) {
1010
const {
1111
stylesheet: { rules }
12-
} = css.parse(`a{${inlineStyle}}`);
12+
} = cssParse(`a{${inlineStyle}}`);
1313
return rules[0].declarations;
1414
}
1515

@@ -25,12 +25,22 @@ function removePosition(declarations) {
2525
}));
2626
}
2727

28+
// compare with `css.parse` declarations
2829
it.each(cases)('parses "%s"', style => {
2930
expect(removePosition(inlineStyleParser(style))).toEqual(
3031
removePosition(getDeclarations(style))
3132
);
3233
});
3334

35+
// match snapshots
3436
it.each(snapshots)('%s', (_name, style) => {
3537
expect(inlineStyleParser(style)).toMatchSnapshot();
3638
});
39+
40+
// one-off
41+
it.each`
42+
style | expected
43+
${':'} | ${[]}
44+
`('parses "%s"', ({ style, expected }) => {
45+
expect(inlineStyleParser(style)).toEqual(expected);
46+
});

0 commit comments

Comments
 (0)