Skip to content

Commit

Permalink
Add CSS preload test
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Oct 16, 2019
1 parent 22acf19 commit 56bb734
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/integration/css/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import {
startApp,
stopApp,
File,
waitFor
waitFor,
renderViaHTTP
} from 'next-test-utils'
import webdriver from 'next-webdriver'
import cheerio from 'cheerio'

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2

Expand Down Expand Up @@ -463,6 +465,19 @@ describe('CSS Support', () => {
}
}
})

it(`should've preloaded the CSS file and injected it in <head>`, async () => {
const content = await renderViaHTTP(appPort, '/page2')
const $ = cheerio.load(content)

const cssPreload = $('link[rel="preload"][as="style"]')
expect(cssPreload.length).toBe(1)
expect(cssPreload.attr('href')).toMatch(/^\/_next\/static\/css\/.*\.css$/)

const cssSheet = $('link[rel="stylesheet"]')
expect(cssSheet.length).toBe(1)
expect(cssSheet.attr('href')).toMatch(/^\/_next\/static\/css\/.*\.css$/)
})
})

describe('CSS URL via `file-loader', () => {
Expand Down

0 comments on commit 56bb734

Please sign in to comment.