Skip to content

Commit

Permalink
Fixed bug #38 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
rstaib authored Jun 11, 2018
1 parent c417a52 commit fb7e25c
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/break/Break.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {shallow} from "enzyme";
import "jest-styled-components";
import React from "react";
import styled from "styled-components";
import Break from "./Break";

describe("<Break />", () => {
Expand Down
1 change: 0 additions & 1 deletion src/column/Column.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {shallow} from "enzyme";
import "jest-styled-components";
import React from "react";
import styled from "styled-components";
import Column from "./Column";

describe("<Column />", () => {
Expand Down
17 changes: 17 additions & 0 deletions src/container/Container.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const containerWidth = {
desktop: 760,
};

const gutterWidth = 100;

storiesOf("Container", module)
.add("fluid", () => (
<Story>
Expand Down Expand Up @@ -53,4 +55,19 @@ storiesOf("Container", module)
</Container>
</ThemeProvider>
</Story>
))
.add("gutterWidth100", () => (
<Story>
<Title>themeProvider</Title>
<ThemeProvider theme={{gutterWidth}}>
<Container>
<Row>
<Column size={3}>1</Column>
<Column size={3}>2</Column>
<Column size={3}>3</Column>
<Column size={3}>4</Column>
</Row>
</Container>
</ThemeProvider>
</Story>
));
1 change: 0 additions & 1 deletion src/container/Container.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {shallow} from "enzyme";
import "jest-styled-components";
import React from "react";
import styled from "styled-components";
import Container from "./Container";

describe("<Container />", () => {
Expand Down
1 change: 0 additions & 1 deletion src/row/Row.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {shallow} from "enzyme";
import "jest-styled-components";
import React from "react";
import styled from "styled-components";
import Row from "./Row";

describe("<Row />", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/row/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const Row = styled.div`
renderJustifyContent(value as RowJustifyContent),
direction: (value?: PropertyValue) =>
renderDirection(value as RowDirection),
gutter: (value?: PropertyValue) => renderGutter(value as boolean),
gutter: (value?: PropertyValue) =>
renderGutter(value as boolean, props.theme),
wrap: (value?: PropertyValue) => renderWrap(value as RowWrap),
};
const valueMap = {
Expand Down
23 changes: 23 additions & 0 deletions src/theme/ThemeProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {mount} from "enzyme";
import "jest-styled-components";
import React from "react";
import {Column, Container, Row} from "..";
import {ThemeProvider} from "./StyledComponents";

describe("<ThemeProvider />", () => {
it("should match the snapshot (gutterWidth set to 100)", () => {
// act
const result = mount(
<ThemeProvider theme={{gutterWidth: 100}}>
<Container>
<Row>
<Column>Test</Column>
</Row>
</Container>
</ThemeProvider>,
);

// assert
expect(result).toMatchSnapshot();
});
});
86 changes: 86 additions & 0 deletions src/theme/__snapshots__/ThemeProvider.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ThemeProvider /> should match the snapshot (gutterWidth set to 100) 1`] = `
.c3 {
position: relative;
width: 100%;
min-height: 1px;
}
.c1 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
margin-right: -50px;
margin-left: -50px;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.c1 > .c2 {
padding-right: 50px;
padding-left: 50px;
}
.c0 {
width: 100%;
margin-right: auto;
margin-left: auto;
padding-right: 50px;
padding-left: 50px;
}
@media (min-width:576px) {
.c0 {
max-width: 540px;
}
}
@media (min-width:768px) {
.c0 {
max-width: 720px;
}
}
@media (min-width:992px) {
.c0 {
max-width: 960px;
}
}
@media (min-width:1200px) {
.c0 {
max-width: 1140px;
}
}
<ThemeProvider
theme={
Object {
"gutterWidth": 100,
}
}
>
<styled.div>
<div
className="c0"
>
<styled.div>
<div
className="c1"
>
<styled.div>
<div
className="c2 c3"
>
Test
</div>
</styled.div>
</div>
</styled.div>
</div>
</styled.div>
</ThemeProvider>
`;

0 comments on commit fb7e25c

Please sign in to comment.