Skip to content

Commit

Permalink
feat(container, row, col): enforce react children
Browse files Browse the repository at this point in the history
  • Loading branch information
mverissimo committed Jun 14, 2020
1 parent d801114 commit c83c0ff
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/components/Col/Col.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Col } from './Col';

describe('Col', () => {
it('should render with default styles', () => {
const { container } = render(<Col />);
const { container } = render(<Col>Col</Col>);

expect(container.firstChild).toMatchSnapshot();
});
Expand All @@ -21,19 +21,19 @@ describe('Col', () => {
] as const;

it.each(sizes)('should render with width styles for media %s', (size) => {
const { container } = render(<Col {...size} />);
const { container } = render(<Col {...size}>Col</Col>);

expect(container.firstChild).toMatchSnapshot();
});

it.each(sizes)('should render with offset styles', (size) => {
const { container } = render(<Col offset={size} />);
const { container } = render(<Col offset={size}>Col</Col>);

expect(container.firstChild).toMatchSnapshot();
});

it.each(sizes)('should render with offset styles for media %s', (size) => {
const { container } = render(<Col offset={size} />);
const { container } = render(<Col offset={size}>Col</Col>);

expect(container.firstChild).toMatchSnapshot();
});
Expand Down
16 changes: 12 additions & 4 deletions src/components/Col/__snapshots__/Col.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ exports[`Col should render with default styles 1`] = `
<div
class="grid-0 grid-1"
/>
>
Col
</div>
`;

exports[`Col should render with offset styles 1`] = `
Expand Down Expand Up @@ -137,7 +139,9 @@ exports[`Col should render with offset styles 1`] = `
<div
class="grid-0 grid-1"
/>
>
Col
</div>
`;

exports[`Col should render with offset styles for media [object Object] 1`] = `
Expand Down Expand Up @@ -222,7 +226,9 @@ exports[`Col should render with offset styles for media [object Object] 1`] = `
<div
class="grid-0 grid-1"
/>
>
Col
</div>
`;

exports[`Col should render with width styles for media [object Object] 1`] = `
Expand Down Expand Up @@ -322,5 +328,7 @@ exports[`Col should render with width styles for media [object Object] 1`] = `
<div
class="grid-0 grid-1"
/>
>
Col
</div>
`;
6 changes: 3 additions & 3 deletions src/components/Container/Container.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { Col } from '../Col';

describe('Container', () => {
it('should render with default styles', () => {
const { container } = render(<Container />);
const { container } = render(<Container>Container</Container>);

expect(container.firstChild).toMatchSnapshot();
});

it('should render with fluid styles when passed the fluid prop', () => {
const { container } = render(<Container fluid />);
const { container } = render(<Container fluid>Container fluid</Container>);

expect(container.firstChild).toMatchSnapshot();
});
Expand All @@ -22,7 +22,7 @@ describe('Container', () => {
const { container } = render(
<Container debug>
<Row>
<Col />
<Col>Col</Col>
</Row>
</Container>
);
Expand Down
12 changes: 9 additions & 3 deletions src/components/Container/__snapshots__/Container.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ exports[`Container should render with debug styles when passed the debug prop 1`
>
<div
class="grid-0 grid-1"
/>
>
Col
</div>
</div>
</div>
`;
Expand Down Expand Up @@ -271,7 +273,9 @@ exports[`Container should render with default styles 1`] = `
<div
class="grid-0 grid-1"
/>
>
Container
</div>
`;

exports[`Container should render with fluid styles when passed the fluid prop 1`] = `
Expand Down Expand Up @@ -319,5 +323,7 @@ exports[`Container should render with fluid styles when passed the fluid prop 1`
<div
class="grid-0 grid-1"
/>
>
Container fluid
</div>
`;
24 changes: 16 additions & 8 deletions src/components/Row/Row.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ describe('Row', () => {
] as const;

it('should render with default styles', () => {
const { container } = render(<Row />);
const { container } = render(<Row>Row</Row>);

expect(container.firstChild).toMatchSnapshot();
});

it('should render with reverse styles when passed the reverse prop', () => {
const { container } = render(<Row reverse />);
const { container } = render(<Row reverse>Row reverse</Row>);

expect(container.firstChild).toMatchSnapshot();
});

it.each(breakpoints)(
'should render reverse styles with breakpoint %s',
(breakpoint) => {
const { container } = render(<Row reverse={[breakpoint]} />);
const { container } = render(
<Row reverse={[breakpoint]}>Row reverse {breakpoint}</Row>
);

expect(container.firstChild).toMatchSnapshot();
}
Expand All @@ -47,37 +49,43 @@ describe('Row', () => {
it.each(align)(
'should render align styles when passed the align %s prop as string',
(propertie) => {
const { container } = render(<Row align={propertie} />);
const { container } = render(
<Row align={propertie}>Row align {propertie}</Row>
);

expect(container.firstChild).toMatchSnapshot();
}
);

it('should render align styles when passed the align prop as object', () => {
const { container } = render(<Row align={{ md: 'center' }} />);
const { container } = render(<Row align={{ md: 'center' }}>Row align</Row>);

expect(container.firstChild).toMatchSnapshot();
});

it.each(justify)(
'should render justify styles when when passed the justify %s prop as string',
(propertie) => {
const { container } = render(<Row justify={propertie} />);
const { container } = render(
<Row justify={propertie}>Row justify {propertie}</Row>
);

expect(container.firstChild).toMatchSnapshot();
}
);

it('should render justify styles when passed the align prop as object', () => {
const { container } = render(<Row justify={{ md: 'center' }} />);
const { container } = render(
<Row justify={{ md: 'center' }}>Row justify</Row>
);

expect(container.firstChild).toMatchSnapshot();
});

it('should render with noGutters styles when passed the noGutters prop', () => {
const { container } = render(
<Row noGutters>
<Col />
<Col>Col</Col>
</Row>
);

Expand Down
Loading

0 comments on commit c83c0ff

Please sign in to comment.