Skip to content

Commit

Permalink
test: dont use data-key
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed May 18, 2023
1 parent ed879ed commit 019772b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
13 changes: 4 additions & 9 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@ describe('basic', async () => {

test('has prefetch link', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="dns-prefetch" href="https://fonts.gstatic.com/">')
expect(body).toContain('<link rel="dns-prefetch" href="https://fonts.gstatic.com/"')
})

test('has preconnect link to font origin', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="anonymous">')
expect(body).toContain('<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="anonymous"')
})

test('has preconnect link to font stylesheet origin', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="preconnect" href="https://fonts.googleapis.com/">')
expect(body).toContain('<link rel="preconnect" href="https://fonts.googleapis.com/"')
})

test('does not have preload link by default', async () => {
const body = await $fetch('/')
expect(body).not.toContain('<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato&display=swap">')
})

test('does not have static stylesheet link', async () => {
const body = await $fetch('/')
expect(body).not.toContain('<link data-hid="gf-style" rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato&display=swap">')
expect(body).not.toContain('<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato&display=swap"')
})

test('has display: swap in font script', async () => {
Expand Down
8 changes: 4 additions & 4 deletions test/use-stylesheet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ describe('use stylesheet', async () => {

test('has prefetch link', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="dns-prefetch" href="https://fonts.gstatic.com/">')
expect(body).toContain('<link rel="dns-prefetch" href="https://fonts.gstatic.com/"')
})

test('has preconnect link', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="anonymous">')
expect(body).toContain('<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="anonymous"')
})

test('has preload link (enabled in config)', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato">')
expect(body).toContain('<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato"')
})

test('has stylesheet link', async () => {
const body = await $fetch('/')
expect(body).toContain('<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato">')
expect(body).toContain('<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato"')
})

test('has stylesheet that does not contain display swap', async () => {
Expand Down

0 comments on commit 019772b

Please sign in to comment.