Skip to content

Commit

Permalink
test(data): add more test cases and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jun 22, 2019
1 parent 513732b commit c9242c7
Showing 1 changed file with 95 additions and 17 deletions.
112 changes: 95 additions & 17 deletions test/data.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,86 @@
const cases = [
// single without semicolon
['color: #f00', { color: '#f00' }],
// general
['display: inline-block;', { display: 'inline-block' }],
['color:red;', { color: 'red' }],
['margin: 0 auto;', { margin: '0 auto' }],
[
'font-size: .75em; position:absolute;width: 33.3%; z-index:1337;',
{
'font-size': '.75em',
position: 'absolute',
width: '33.3%',
'z-index': '1337'
}
],
[
'font-family: "Goudy Bookletter 1911", Gill Sans Extrabold, sans-serif;',
{
'font-family': '"Goudy Bookletter 1911", Gill Sans Extrabold, sans-serif'
}
],

// multiple with semicolons
// multiple of same property
[
'font-size: 42px; font-family: "Open Sans", Helvetica, sans-serif;',
'color:rgba(0,0,0,1);color:white;',
{
'font-size': '42px',
'font-family': '"Open Sans", Helvetica, sans-serif'
color: 'white'
}
],

// url
// missing semicolon
['line-height: 42', { 'line-height': '42' }],
[
'background-image: url("http://cdn.example.com/image.png?v=42");',
'font-style:italic; text-transform:uppercase',
{ 'font-style': 'italic', 'text-transform': 'uppercase' }
],

// extra whitespace
[' padding-bottom : 1px', { 'padding-bottom': '1px' }],
['padding: 12px 0 ', { padding: '12px 0' }],
[
`
-moz-border-radius: 10px 5px;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 10px;
-webkit-border-bottom-left-radius: 5px;
border-radius: 10px 5px;
`,
{
'-moz-border-radius': '10px 5px',
'-webkit-border-top-left-radius': '10px',
'-webkit-border-top-right-radius': '5px',
'-webkit-border-bottom-right-radius': '10px',
'-webkit-border-bottom-left-radius': '5px',
'border-radius': '10px 5px'
}
],

// text and url
['content: "Lorem ipsum";', { content: '"Lorem ipsum"' }],
['content: "foo: bar;";', { content: '"foo: bar;"' }],
[
('background-image: url("http://cdn.example.com/image.png?v=42");',
{
'background-image': 'url("http://cdn.example.com/image.png?v=42")'
})
],
[
'background: #123456 url("https://foo.bar/image.png?v=2")',
{
background: '#123456 url("https://foo.bar/image.png?v=2")'
}
],

// property prefix
[
'-webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto; hyphens: auto;',
('-webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto; hyphens: auto;',
{
'-webkit-hyphens': 'auto',
'-moz-hyphens': 'auto',
'-ms-hyphens': 'auto',
hyphens: 'auto'
}
})
],

// value prefix
Expand All @@ -38,14 +91,32 @@ const cases = [
}
],

// missing value
['z-index:', null],

// comment
['/* color: #f00; */', null],
['/* color: #f00; */ background: blue;', { background: 'blue' }],
[
'top: 0; /* comment */ bottom: 42rem;',
{
top: '0',
bottom: '42rem'
}
],
[
` right: 0; /* comment */
/* comment */ left: 42rem; `,
{
right: '0',
left: '42rem'
}
],

// comment with declaration
['/* color: #f00; */ background: blue;', { background: 'blue' }]
// custom
[
'foo: bar;',
{
foo: 'bar'
}
],
['foo:bar; baz:qux', { foo: 'bar', baz: 'qux' }]
];

const errors = [
Expand All @@ -67,7 +138,14 @@ const invalids = [
{},
['Array'],
() => Function,
new Date()
new Date(),

// missing value
'z-index:',

// comment
'/* color: #f00; */',
'/**/'
];

module.exports = {
Expand Down

0 comments on commit c9242c7

Please sign in to comment.