Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Mar 2, 2020
1 parent c85a3d9 commit 6ead1b4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/integration/preload-viewport/test/index.test.js
Expand Up @@ -9,6 +9,7 @@ import {
} from 'next-test-utils'
import webdriver from 'next-webdriver'
import { join } from 'path'
import { readFile } from 'fs-extra'
import { parse } from 'url'

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
Expand Down Expand Up @@ -246,6 +247,25 @@ describe('Prefetching Links in viewport', () => {
expect(calledPrefetch).toBe(true)
})

it('should correctly omit pre-generaged dynamic pages from SSG manifest', async () => {
const content = await readFile(
join(appDir, '.next', 'static', 'test-build', '_ssgManifest.js'),
'utf8'
)

let self = {}
// eslint-disable-next-line no-eval
eval(content)
expect([...self.__SSG_MANIFEST].sort()).toMatchInlineSnapshot(`
Array [
"/ssg/basic",
"/ssg/catch-all/[...slug]",
"/ssg/dynamic-nested/[slug1]/[slug2]",
"/ssg/dynamic/[slug]",
]
`)
})

it('should prefetch data files', async () => {
const browser = await webdriver(appPort, '/ssg/fixture')
await waitFor(2 * 1000) // wait for prefetching to occur
Expand Down

0 comments on commit 6ead1b4

Please sign in to comment.