Remove dublicate className from head (followup) (#5027)

* Add test of default head.

* Remove duplicate next-head (followup #5026)
This commit is contained in:
HaNdTriX 2018-08-25 10:00:57 +02:00 committed by GitHub
parent 267cff3b81
commit 4c6ec18d89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View file

@ -29,7 +29,7 @@ function reduceComponents (components) {
return a.concat(b)
}, [])
.reverse()
.concat(defaultHead())
.concat(defaultHead(''))
.filter(Boolean)
.filter(unique())
.reverse()

View file

@ -0,0 +1,7 @@
import React from 'react'
import Head from 'next/head'
export default () => <div>
<Head />
<h1>next-head, but only once.</h1>
</div>

View file

@ -28,6 +28,7 @@ describe('Basic Features', () => {
// pre-build all pages at the start
await Promise.all([
renderViaHTTP(context.appPort, '/async-props'),
renderViaHTTP(context.appPort, '/default-head'),
renderViaHTTP(context.appPort, '/empty-get-initial-props'),
renderViaHTTP(context.appPort, '/error'),
renderViaHTTP(context.appPort, '/finish-response'),

View file

@ -26,6 +26,13 @@ export default function ({ app }, suiteName, render, fetch) {
expect(answer.text()).toBe('The answer is 42')
})
// default-head contains an empty <Head />.
test('header renders default charset', async () => {
const html = await (render('/default-head'))
expect(html.includes('<meta charSet="utf-8" class="next-head"/>')).toBeTruthy()
expect(html.includes('next-head, but only once.')).toBeTruthy()
})
test('header helper renders header information', async () => {
const html = await (render('/head'))
expect(html.includes('<meta charSet="iso-8859-5" class="next-head"/>')).toBeTruthy()