Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/improve test for deduplication of tags with same key in Head #9793

Merged
merged 2 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ export default () => (
<Head>
{/* this will not render */}
<meta charSet="utf-8" key="charSet" />
{/* this will override the default (same key as the default) */}
<meta charSet="iso-8859-5" key="charSet" />

{/* this will not render */}
<meta name="viewport" content="width=device-width" key="viewport" />
{/* this will override the default (same key as the default) */}
<meta
name="viewport"
content="width=device-width,initial-scale=1"
key="viewport"
/>
<meta charSet="iso-8859-5" key="charSet" />
{/* this will render instead of the default */}
<meta name="viewport" content="width=500" key="viewport" />
</Head>
<Head>
{/* this will override the the above */}
<meta charSet="iso-8859-1" key="charSet" />
</Head>
<h1>Meta tags with same keys as default get deduped</h1>
</div>
Expand Down
12 changes: 6 additions & 6 deletions test/integration/client-navigation/test/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ export default function(render, fetch) {

test('header helper dedupes tags with the same key as the default', async () => {
const html = await render('/head-duplicate-default-keys')
expect(html).toContain('<meta charSet="iso-8859-5"/>')
expect(html).not.toContain('<meta charSet="utf-8"/>')
expect(html).toContain(
'<meta name="viewport" content="width=device-width,initial-scale=1"/>'
)
expect(html).not.toContain('<meta name="width=device-width"/>')
// Expect exactly one `charSet`
expect((html.match(/charSet=/g) || []).length).toBe(1)
// Expect exactly one `viewport`
expect((html.match(/name="viewport"/g) || []).length).toBe(1)
expect(html).toContain('<meta charSet="iso-8859-1"/>')
expect(html).toContain('<meta name="viewport" content="width=500"/>')
})

test('header helper avoids dedupe of specific tags', async () => {
Expand Down