From fb49f4e42a774f5909b528be400ae51b57c9343a Mon Sep 17 00:00:00 2001 From: Bruno Date: Wed, 17 Apr 2019 10:40:02 -0300 Subject: [PATCH] fix(appbar): make allowed children to accept additional props --- src/components/Appbar/Appbar.js | 9 +- .../__tests__/Appbar/Appbar.test.js | 14 + .../Appbar/__snapshots__/Appbar.test.js.snap | 305 ++++++++++++++++++ 3 files changed, 322 insertions(+), 6 deletions(-) diff --git a/src/components/Appbar/Appbar.js b/src/components/Appbar/Appbar.js index 539c1fcf34..7c49a466ce 100644 --- a/src/components/Appbar/Appbar.js +++ b/src/components/Appbar/Appbar.js @@ -135,12 +135,9 @@ class Appbar extends React.Component { .map((child, i) => { if ( !React.isValidElement(child) || - ![ - 'AppbarContent', - 'AppbarAction', - 'AppbarBackAction', - 'AppbarHeader', - ].includes(child.type.name) + ![AppbarContent, AppbarAction, AppbarBackAction].includes( + child.type + ) ) { return child; } diff --git a/src/components/__tests__/Appbar/Appbar.test.js b/src/components/__tests__/Appbar/Appbar.test.js index 6dfcf5da54..1c07030f23 100644 --- a/src/components/__tests__/Appbar/Appbar.test.js +++ b/src/components/__tests__/Appbar/Appbar.test.js @@ -15,4 +15,18 @@ describe('Appbar', () => { expect(tree).toMatchSnapshot(); }); + + it('passes additional props to AppbarBackAction, AppbarContent and AppbarAction', () => { + const tree = renderer + .create( + + {}} /> + + {}} /> + + ) + .toJSON(); + + expect(tree).toMatchSnapshot(); + }); }); diff --git a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap index 60343d3311..aa0881d0dc 100644 --- a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap +++ b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap @@ -232,3 +232,308 @@ exports[`Appbar does not pass any additional props to Searchbar 1`] = ` `; + +exports[`Appbar passes additional props to AppbarBackAction, AppbarContent and AppbarAction 1`] = ` + + + + + + + + + + + + + + + Examples + + + + + + + +  + + + + + + +`;