From 177d6b8bf0c772da5710c6e15196b5cf667571fb Mon Sep 17 00:00:00 2001 From: Misha Moroshko Date: Fri, 6 Mar 2020 13:41:46 +1100 Subject: [PATCH] Don't check component type (it's broken) --- src/components/Flex.test.js | 4 +--- src/components/Footer.js | 14 ++++++++++---- src/components/List.js | 13 +++++++++---- src/components/List.test.js | 15 --------------- src/components/Stepper.js | 15 +++++++++++---- website/src/components/ComponentPreview.js | 2 +- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/components/Flex.test.js b/src/components/Flex.test.js index 36fbd75b..ad953fcb 100644 --- a/src/components/Flex.test.js +++ b/src/components/Flex.test.js @@ -14,9 +14,7 @@ describe("Flex", () => { it("with testId", () => { const { container } = render( - - Content goes here - + Content goes here ); expect(container.firstChild).toHaveAttribute("data-testid", "my-flex"); diff --git a/src/components/Footer.js b/src/components/Footer.js index f6488a6e..b71fa76f 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -153,10 +153,16 @@ Header.propTypes = { }; function LegalLinks({ children, testId }) { - const links = React.Children.toArray(children).filter( - // Ignore all children that aren't a Link - child => child.type === Link - ); + const links = React.Children.toArray(children); + + /* + This stopped working at some point, so filtering here would result in []. + + .filter( + // Ignore all children that aren't a Link + child => child.type === Link + ); + */ return ( diff --git a/src/components/List.js b/src/components/List.js index f409928a..c4ef7c4a 100644 --- a/src/components/List.js +++ b/src/components/List.js @@ -67,10 +67,15 @@ function List(props) { margin: responsiveMargin }); const ListComponent = type === "unordered" ? "ul" : "ol"; - const items = React.Children.toArray(children).filter( - // Ignore all children that aren't List.Item - child => child.type === Item - ); + const items = React.Children.toArray(children); + /* + This stopped working at some point, so filtering here would result in []. + + .filter( + // Ignore all children that aren't List.Item + child => child.type === Item + ); + */ let list = ( { getByText("Last Item"); }); - it("ignores children that are not List.Item", () => { - const { queryByText } = render( - -

Hello

- First Item - Second Item -
World
- Third Item -
- ); - - expect(queryByText("Hello")).not.toBeInTheDocument(); - expect(queryByText("World")).not.toBeInTheDocument(); - }); - it("with testId", () => { const { container } = render( diff --git a/src/components/Stepper.js b/src/components/Stepper.js index 1d6861aa..b2222e9f 100644 --- a/src/components/Stepper.js +++ b/src/components/Stepper.js @@ -100,10 +100,17 @@ function Stepper(_props) { const props = { ...DEFAULT_PROPS, ..._props }; const { completed, children, testId } = props; const theme = useTheme(); - const steps = React.Children.toArray(children).filter( - // Ignore all children that aren't Step.Item - child => child.type === Item - ); + const steps = React.Children.toArray(children); + + /* + This stopped working at some point, so filtering here would result in []. + + .filter( + // Ignore all children that aren't Step.Item + child => child.type === Item + ); + */ + const currentStepIndex = steps.findIndex(step => step.props.current === true); return ( diff --git a/website/src/components/ComponentPreview.js b/website/src/components/ComponentPreview.js index 33575f9f..4e5387b7 100644 --- a/website/src/components/ComponentPreview.js +++ b/website/src/components/ComponentPreview.js @@ -32,7 +32,7 @@ function LivePreviewWrapper({ containerRef, highlightedComponents, children }) {