Skip to content

Commit

Permalink
Fix/improve test for deduplication of tags with same key (#9793)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manc authored and timneutkens committed Dec 24, 2019
1 parent 632e40f commit 5909e67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
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

0 comments on commit 5909e67

Please sign in to comment.