3aed76fad8
* Unflag Dynamic Routing * Unflag Automatic Prerendering * Ensure pages are lambdas for test * Fix file check * Fix tests * oof * Use lambda for document middleware test
68 lines
2.4 KiB
JavaScript
68 lines
2.4 KiB
JavaScript
/* eslint-env jest */
|
|
/* global jasmine */
|
|
import fs from 'fs'
|
|
import { join } from 'path'
|
|
import cheerio from 'cheerio'
|
|
import { promisify } from 'util'
|
|
import { nextBuild, nextExport } from 'next-test-utils'
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
|
|
const readFile = promisify(fs.readFile)
|
|
const access = promisify(fs.access)
|
|
const appDir = join(__dirname, '../')
|
|
const outdir = join(appDir, 'out')
|
|
|
|
describe('Export with default map', () => {
|
|
beforeAll(async () => {
|
|
await nextBuild(appDir)
|
|
await nextExport(appDir, { outdir })
|
|
})
|
|
|
|
it('should export with folder that has dot in name', async () => {
|
|
expect.assertions(1)
|
|
await expect(access(join(outdir, 'v1.12.html'))).resolves.toBe(undefined)
|
|
})
|
|
|
|
it('should export an amp only page to clean path', async () => {
|
|
expect.assertions(1)
|
|
await expect(access(join(outdir, 'docs.html'))).resolves.toBe(undefined)
|
|
})
|
|
|
|
it('should export hybrid amp page correctly', async () => {
|
|
expect.assertions(2)
|
|
await expect(access(join(outdir, 'some.html'))).resolves.toBe(undefined)
|
|
await expect(access(join(outdir, 'some.amp.html'))).resolves.toBe(undefined)
|
|
})
|
|
|
|
it('should export nested hybrid amp page correctly', async () => {
|
|
expect.assertions(3)
|
|
await expect(access(join(outdir, 'docs.html'))).resolves.toBe(undefined)
|
|
await expect(access(join(outdir, 'docs.amp.html'))).resolves.toBe(undefined)
|
|
|
|
const html = await readFile(join(outdir, 'docs.html'))
|
|
const $ = cheerio.load(html)
|
|
expect($('link[rel=amphtml]').attr('href')).toBe('/docs.amp')
|
|
})
|
|
|
|
it('should export nested hybrid amp page correctly with folder', async () => {
|
|
expect.assertions(3)
|
|
await expect(access(join(outdir, 'info.html'))).resolves.toBe(undefined)
|
|
await expect(access(join(outdir, 'info.amp.html'))).resolves.toBe(undefined)
|
|
|
|
const html = await readFile(join(outdir, 'info.html'))
|
|
const $ = cheerio.load(html)
|
|
expect($('link[rel=amphtml]').attr('href')).toBe('/info.amp')
|
|
})
|
|
|
|
it('should export hybrid index amp page correctly', async () => {
|
|
expect.assertions(3)
|
|
await expect(access(join(outdir, 'index.html'))).resolves.toBe(undefined)
|
|
await expect(access(join(outdir, 'index.amp.html'))).resolves.toBe(
|
|
undefined
|
|
)
|
|
|
|
const html = await readFile(join(outdir, 'index.html'))
|
|
const $ = cheerio.load(html)
|
|
expect($('link[rel=amphtml]').attr('href')).toBe('/index.amp')
|
|
})
|
|
})
|