Skip to content

Commit

Permalink
test: add check for case-insensitive font-family pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Ohlsson Aden committed Oct 1, 2020
1 parent f95de9f commit ffc4c12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/post-formatting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ describe('penthouse post formatting tests', () => {
expect(csstree.generate(ast)).toEqual(normaliseCss(expectedCss))
})

it('should treat font-family names as case-insensitive', () => {
// contains mismatched case for font-name between @font-face and usage ("Roboto" vs "roboto")
// - should be kept regardless
const cssString = "@font-face{font-family:'Roboto';font-style:normal;font-weight:300;src:local('Roboto Light')}#one{color:red;font-family:'roboto';font-weight:300}#one{color:blue}"
return penthouse({
url: staticServerFileUrl('case-sensitive.html'),
cssString
})
.then(css => {
expect(css).toEqual(normaliseCss(cssString))
})
})

it('should only keep @keyframe rules used in critical css', () => {
const originalCss = read(path.join(process.env.PWD, 'test', 'static-server', 'unused-keyframes.css'), 'utf8')
const expectedCss = read(path.join(process.env.PWD, 'test', 'static-server', 'unused-keyframes--expected.css'), 'utf8')
Expand Down
7 changes: 7 additions & 0 deletions test/static-server/case-sensitive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head>
</head>
<body>
<div id="one">Lorem ipsum</div>
</body>
</html>

0 comments on commit ffc4c12

Please sign in to comment.