Skip to content

Commit d0ed3bd

Browse files
test(index): verify that expected errors are thrown
1 parent a08f521 commit d0ed3bd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/data.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,24 @@ const snapshots = [
6868
]
6969
];
7070

71+
const errors = [
72+
undefined,
73+
null,
74+
true,
75+
false,
76+
0,
77+
1,
78+
{},
79+
Object,
80+
Array,
81+
Date,
82+
Function,
83+
() => {},
84+
'overflow'
85+
];
86+
7187
module.exports = {
7288
cases,
89+
errors,
7390
snapshots
7491
};

test/index.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const cssParse = require('css/lib/parse');
22
const inlineStyleParser = require('..');
3-
const { cases, snapshots } = require('./data');
3+
const { cases, errors, snapshots } = require('./data');
44

55
/**
66
* @param {string} inlineStyle
@@ -37,6 +37,11 @@ it.each(snapshots)('%s', (_name, style) => {
3737
expect(inlineStyleParser(style)).toMatchSnapshot();
3838
});
3939

40+
// errors
41+
it.each(errors)('throws error when argument is "%s"', value => {
42+
expect(() => inlineStyleParser(value)).toThrow();
43+
});
44+
4045
// one-off
4146
it.each`
4247
style | expected

0 commit comments

Comments
 (0)