tailwindcss/jest/customMatchers.js
2017-11-23 09:58:25 -05:00

22 lines
560 B
JavaScript

expect.extend({
// Compare two CSS strings with all whitespace removed
// This is probably naive but it's fast and works well enough.
toMatchCss(received, argument) {
function stripped(str) {
return str.replace(/\s/g, '')
}
if (stripped(received) === stripped(argument)) {
return {
message: () => `expected ${received} not to match CSS ${argument}`,
pass: true,
}
} else {
return {
message: () => `expected ${received} to match CSS ${argument}`,
pass: false,
}
}
},
})