From 06f354cca1af9f055ab018389e8de41bdd9ab2b1 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sat, 11 Feb 2017 15:22:36 +0100 Subject: [PATCH] add tests to check that grip, grip-array, grip-map don't forward title to children --- src/test/mochitest/head.js | 4 ++-- src/test/mochitest/test_reps_grip-array.html | 7 +++++++ src/test/mochitest/test_reps_grip-map.html | 7 +++++++ src/test/mochitest/test_reps_grip.html | 7 +++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/test/mochitest/head.js b/src/test/mochitest/head.js index f386e37..3b2043e 100644 --- a/src/test/mochitest/head.js +++ b/src/test/mochitest/head.js @@ -47,7 +47,7 @@ function shallowRenderComponent(component, props) { */ function testRepRenderModes(modeTests, testName, componentUnderTest, gripStub, props = {}) { - modeTests.forEach(({mode, expectedOutput, message}) => { + modeTests.forEach(({mode, expectedOutput, message, title}) => { const modeString = typeof mode === "undefined" ? "no mode" : mode.toString(); if (!message) { message = `${testName}: ${modeString} renders correctly.`; @@ -55,7 +55,7 @@ function testRepRenderModes(modeTests, testName, componentUnderTest, gripStub, const rendered = renderComponent( componentUnderTest.rep, - Object.assign({}, { object: gripStub, mode }, props) + Object.assign({}, { object: gripStub, mode, title }, props) ); is(rendered.textContent, expectedOutput, message); }); diff --git a/src/test/mochitest/test_reps_grip-array.html b/src/test/mochitest/test_reps_grip-array.html index 220233d..1167612 100644 --- a/src/test/mochitest/test_reps_grip-array.html +++ b/src/test/mochitest/test_reps_grip-array.html @@ -108,6 +108,13 @@ { mode: MODE.LONG, expectedOutput: defaultOutput, + }, + { + // Check the custom title with nested objects to make sure nested objects are not + // displayed with their parent's title. + mode: MODE.LONG, + title: "CustomTitle", + expectedOutput: `CustomTitle [ 1, "foo", Object ]`, } ]; diff --git a/src/test/mochitest/test_reps_grip-map.html b/src/test/mochitest/test_reps_grip-map.html index 30a4fed..2ce0b0e 100644 --- a/src/test/mochitest/test_reps_grip-map.html +++ b/src/test/mochitest/test_reps_grip-map.html @@ -138,6 +138,13 @@ { mode: MODE.LONG, expectedOutput: defaultOutput, + }, + { + // Check the custom title with nested objects to make sure nested objects are not + // displayed with their parent's title. + mode: MODE.LONG, + title: "CustomTitle", + expectedOutput: `CustomTitle { Object: "value-a" }`, } ]; diff --git a/src/test/mochitest/test_reps_grip.html b/src/test/mochitest/test_reps_grip.html index 4fd3d60..4652ac8 100644 --- a/src/test/mochitest/test_reps_grip.html +++ b/src/test/mochitest/test_reps_grip.html @@ -460,6 +460,13 @@ { mode: MODE.LONG, expectedOutput: defaultOutput, + }, + { + // Check the custom title with nested objects to make sure nested objects are not + // displayed with their parent's title. + mode: MODE.LONG, + title: "CustomTitle", + expectedOutput: `CustomTitle { objProp: Object, strProp: "test string" }`, } ];