Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Nov 1, 2019
1 parent 3840f0d commit a616abb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/subsetFonts.js
Expand Up @@ -4210,6 +4210,36 @@ describe('subsetFonts', function() {
expect(cssAsset.text, 'not to contain', 'font-style:italic');
});
});

describe('with a page that does need subsetting and one that does', function() {
// https://gitter.im/assetgraph/assetgraph?at=5dbb6438a3f0b17849c488cf
it('should not short circuit because the first page does not need any subset fonts', async function() {
const assetGraph = new AssetGraph({
root: pathModule.resolve(
__dirname,
'../testdata/subsetFonts/firstPageNoSubset/'
)
});
await assetGraph.loadAssets(['index-1.html', 'index-2.html']);
await assetGraph.populate();
const { fontInfo } = await subsetFonts(assetGraph, {
inlineFonts: false,
omitFallbacks: true
});

expect(fontInfo, 'to satisfy', [
{ htmlAsset: /\/index-1\.html$/, fontUsages: [] },
{
htmlAsset: /\/index-2\.html$/,
fontUsages: [
{
text: ' ABCDEFGHIJKLM'
}
]
}
]);
});
});
});

describe('with non-truetype fonts in the mix', function() {
Expand Down
Binary file not shown.
17 changes: 17 additions & 0 deletions testdata/subsetFonts/firstPageNoSubset/index-1.html
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
@font-face {
font-family: 'IBM Plex Sans';
font-style: normal;
font-weight: 400;
src: url('IBMPlexSans-Regular.woff') format('woff');
}
</style>
</head>
<body>
ABCDEFGHIJKLMNOPQRSTUVWXYZ
</body>
</html>
23 changes: 23 additions & 0 deletions testdata/subsetFonts/firstPageNoSubset/index-2.html
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
@font-face {
font-family: 'IBM Plex Sans';
font-style: normal;
font-weight: 400;
src: url('IBMPlexSans-Regular.woff') format('woff');
}

body {
font-family: 'IBM Plex Sans', sans-serif;
font-style: normal;
font-weight: 400;
}
</style>
</head>
<body>
ABCDEFGHIJKLM
</body>
</html>

0 comments on commit a616abb

Please sign in to comment.