Commit 336019b8 authored by Janka Uryga's avatar Janka Uryga

test: convert metadata.test.ts to nextTestSetup

parent 9bb06c54
import type { BrowserInterface } from 'next-webdriver' import type { BrowserInterface } from 'next-webdriver'
import { createNextDescribe } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils' import { check } from 'next-test-utils'
import fs from 'fs/promises' import fs from 'fs/promises'
import path from 'path' import path from 'path'
import cheerio from 'cheerio' import cheerio from 'cheerio'
createNextDescribe( describe('app dir - metadata', () => {
'app dir - metadata', const { next, isNextDev, isNextStart, isNextDeploy } = nextTestSetup({
{
files: __dirname, files: __dirname,
}, })
({ next, isNextDev, isNextStart, isNextDeploy }) => {
const getTitle = (browser: BrowserInterface) => const getTitle = (browser: BrowserInterface) =>
browser.elementByCss('title').text() browser.elementByCss('title').text()
...@@ -195,9 +194,7 @@ createNextDescribe( ...@@ -195,9 +194,7 @@ createNextDescribe(
expect(await $inner('title').text()).toBe('Inner Page | Extra Layout') expect(await $inner('title').text()).toBe('Inner Page | Extra Layout')
const $deep = await next.render$('/title-template/extra/inner/deep') const $deep = await next.render$('/title-template/extra/inner/deep')
expect(await $deep('title').text()).toBe( expect(await $deep('title').text()).toBe('extra layout default | Layout')
'extra layout default | Layout'
)
}) })
it('should support other basic tags', async () => { it('should support other basic tags', async () => {
...@@ -716,9 +713,9 @@ createNextDescribe( ...@@ -716,9 +713,9 @@ createNextDescribe(
const faviconResponse = Buffer.from( const faviconResponse = Buffer.from(
await next.fetch('/favicon.ico').then((res) => res.arrayBuffer()) await next.fetch('/favicon.ico').then((res) => res.arrayBuffer())
) )
return expect( return expect(Buffer.compare(faviconResponse, faviconFileBuffer)).toBe(
Buffer.compare(faviconResponse, faviconFileBuffer) 0
).toBe(0) )
} }
}) })
}) })
...@@ -914,9 +911,7 @@ createNextDescribe( ...@@ -914,9 +911,7 @@ createNextDescribe(
it('should support static manifest.webmanifest', async () => { it('should support static manifest.webmanifest', async () => {
const res = await next.fetch('/manifest.webmanifest') const res = await next.fetch('/manifest.webmanifest')
expect(res.headers.get('content-type')).toBe( expect(res.headers.get('content-type')).toBe('application/manifest+json')
'application/manifest+json'
)
const manifest = await res.json() const manifest = await res.json()
expect(manifest).toMatchObject({ expect(manifest).toMatchObject({
name: 'Next.js Static Manifest', name: 'Next.js Static Manifest',
...@@ -1025,5 +1020,4 @@ createNextDescribe( ...@@ -1025,5 +1020,4 @@ createNextDescribe(
const res = await next.fetch('/dynamic-meta') const res = await next.fetch('/dynamic-meta')
expect(res.status).toBe(404) expect(res.status).toBe(404)
}) })
} })
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment