From 5909e677652e8bf437cb7e721e32a5f9f6d81338 Mon Sep 17 00:00:00 2001 From: Nick Zahn Date: Tue, 24 Dec 2019 15:22:04 +0000 Subject: [PATCH] Fix/improve test for deduplication of tags with same key (#9793) --- .../pages/head-duplicate-default-keys.js | 17 +++++++---------- .../client-navigation/test/rendering.js | 12 ++++++------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/test/integration/client-navigation/pages/head-duplicate-default-keys.js b/test/integration/client-navigation/pages/head-duplicate-default-keys.js index 9f81993679fa0..b3848d0559e8d 100644 --- a/test/integration/client-navigation/pages/head-duplicate-default-keys.js +++ b/test/integration/client-navigation/pages/head-duplicate-default-keys.js @@ -6,17 +6,14 @@ export default () => ( {/* this will not render */} - {/* this will override the default (same key as the default) */} - - {/* this will not render */} - - {/* this will override the default (same key as the default) */} - + + {/* this will render instead of the default */} + + + + {/* this will override the the above */} +

Meta tags with same keys as default get deduped

diff --git a/test/integration/client-navigation/test/rendering.js b/test/integration/client-navigation/test/rendering.js index 8143c93a1ba22..b7679fbb45796 100644 --- a/test/integration/client-navigation/test/rendering.js +++ b/test/integration/client-navigation/test/rendering.js @@ -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('') - expect(html).not.toContain('') - expect(html).toContain( - '' - ) - expect(html).not.toContain('') + // 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('') + expect(html).toContain('') }) test('header helper avoids dedupe of specific tags', async () => {