|
| 1 | +import { readFile } from 'node:fs/promises' |
1 | 2 | import { fileURLToPath } from 'node:url' |
2 | 3 | import { describe, it, expect } from 'vitest' |
3 | | -import { setup, $fetch, fetch } from '@nuxt/test-utils' |
| 4 | +import { setup, $fetch, fetch, useTestContext } from '@nuxt/test-utils' |
| 5 | +import { glob } from 'tinyglobby' |
4 | 6 |
|
5 | 7 | import { mockAdobeFetch } from './fixtures/adobe/index.ts' |
6 | 8 | import { extractFontFaces, extractPreloadLinks } from './utils.ts' |
@@ -187,6 +189,13 @@ describe('features', () => { |
187 | 189 | expect(html).toContain('font-family:Anton,Anton Fallback\\: Segoe UI') |
188 | 190 | }) |
189 | 191 |
|
| 192 | + it('should generate fallback metrics for global families once in bundled stylesheets', async () => { |
| 193 | + const [file] = await glob('public/_nuxt/global.*.css', { cwd: useTestContext().nuxt!.options.nitro.output!.dir, absolute: true }) |
| 194 | + const css = await readFile(file!, 'utf8') |
| 195 | + expect(css).not.toContain('Anton Fallback: Anton Fallback') |
| 196 | + expect(extractFontFaces('Anton Fallback: Arial', css)).toHaveLength(1) |
| 197 | + }) |
| 198 | + |
190 | 199 | it('should not duplicate the font face or preload hints of a global family at its usage site', async () => { |
191 | 200 | const html = await $fetch<string>('/global') |
192 | 201 | expect(extractFontFaces('Anton', html)).toMatchInlineSnapshot(` |
|
0 commit comments