Skip to content

Commit

Permalink
Merge pull request #31 from moroshko/cleanup
Browse files Browse the repository at this point in the history
Don't check component type (it's broken in dev)
  • Loading branch information
moroshko authored Mar 6, 2020
2 parents 61c87c6 + 177d6b8 commit db6e6d2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
4 changes: 1 addition & 3 deletions src/components/Flex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ describe("Flex", () => {

it("with testId", () => {
const { container } = render(
<Flex gap="2" testId="my-flex">
Content goes here
</Flex>
<Flex testId="my-flex">Content goes here</Flex>
);

expect(container.firstChild).toHaveAttribute("data-testid", "my-flex");
Expand Down
14 changes: 10 additions & 4 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Flex gap="3 4" wrap placeItems="top center" testId={testId}>
Expand Down
13 changes: 9 additions & 4 deletions src/components/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<ListComponent
Expand Down
15 changes: 0 additions & 15 deletions src/components/List.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@ describe("List", () => {
getByText("Last Item");
});

it("ignores children that are not List.Item", () => {
const { queryByText } = render(
<List>
<p>Hello</p>
<List.Item>First Item</List.Item>
<List.Item>Second Item</List.Item>
<div>World</div>
<List.Item>Third Item</List.Item>
</List>
);

expect(queryByText("Hello")).not.toBeInTheDocument();
expect(queryByText("World")).not.toBeInTheDocument();
});

it("with testId", () => {
const { container } = render(
<List testId="my-list">
Expand Down
15 changes: 11 additions & 4 deletions src/components/Stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/ComponentPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function LivePreviewWrapper({ containerRef, highlightedComponents, children }) {
<div
css={{
position: "relative",
minHeight: "100vh"
height: "100vh"
}}
ref={containerRef}
>
Expand Down

1 comment on commit db6e6d2

@vercel
Copy link

@vercel vercel bot commented on db6e6d2 Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.