Skip to content

Commit fb7e25c

Browse files
authored
Fixed bug #38 (#39)
1 parent c417a52 commit fb7e25c

8 files changed

+128
-5
lines changed

src/break/Break.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {shallow} from "enzyme";
22
import "jest-styled-components";
33
import React from "react";
4-
import styled from "styled-components";
54
import Break from "./Break";
65

76
describe("<Break />", () => {

src/column/Column.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {shallow} from "enzyme";
22
import "jest-styled-components";
33
import React from "react";
4-
import styled from "styled-components";
54
import Column from "./Column";
65

76
describe("<Column />", () => {

src/container/Container.story.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const containerWidth = {
1919
desktop: 760,
2020
};
2121

22+
const gutterWidth = 100;
23+
2224
storiesOf("Container", module)
2325
.add("fluid", () => (
2426
<Story>
@@ -53,4 +55,19 @@ storiesOf("Container", module)
5355
</Container>
5456
</ThemeProvider>
5557
</Story>
58+
))
59+
.add("gutterWidth100", () => (
60+
<Story>
61+
<Title>themeProvider</Title>
62+
<ThemeProvider theme={{gutterWidth}}>
63+
<Container>
64+
<Row>
65+
<Column size={3}>1</Column>
66+
<Column size={3}>2</Column>
67+
<Column size={3}>3</Column>
68+
<Column size={3}>4</Column>
69+
</Row>
70+
</Container>
71+
</ThemeProvider>
72+
</Story>
5673
));

src/container/Container.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {shallow} from "enzyme";
22
import "jest-styled-components";
33
import React from "react";
4-
import styled from "styled-components";
54
import Container from "./Container";
65

76
describe("<Container />", () => {

src/row/Row.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {shallow} from "enzyme";
22
import "jest-styled-components";
33
import React from "react";
4-
import styled from "styled-components";
54
import Row from "./Row";
65

76
describe("<Row />", () => {

src/row/Row.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const Row = styled.div`
3030
renderJustifyContent(value as RowJustifyContent),
3131
direction: (value?: PropertyValue) =>
3232
renderDirection(value as RowDirection),
33-
gutter: (value?: PropertyValue) => renderGutter(value as boolean),
33+
gutter: (value?: PropertyValue) =>
34+
renderGutter(value as boolean, props.theme),
3435
wrap: (value?: PropertyValue) => renderWrap(value as RowWrap),
3536
};
3637
const valueMap = {

src/theme/ThemeProvider.test.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {mount} from "enzyme";
2+
import "jest-styled-components";
3+
import React from "react";
4+
import {Column, Container, Row} from "..";
5+
import {ThemeProvider} from "./StyledComponents";
6+
7+
describe("<ThemeProvider />", () => {
8+
it("should match the snapshot (gutterWidth set to 100)", () => {
9+
// act
10+
const result = mount(
11+
<ThemeProvider theme={{gutterWidth: 100}}>
12+
<Container>
13+
<Row>
14+
<Column>Test</Column>
15+
</Row>
16+
</Container>
17+
</ThemeProvider>,
18+
);
19+
20+
// assert
21+
expect(result).toMatchSnapshot();
22+
});
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<ThemeProvider /> should match the snapshot (gutterWidth set to 100) 1`] = `
4+
.c3 {
5+
position: relative;
6+
width: 100%;
7+
min-height: 1px;
8+
}
9+
10+
.c1 {
11+
display: -webkit-box;
12+
display: -webkit-flex;
13+
display: -ms-flexbox;
14+
display: flex;
15+
margin-right: -50px;
16+
margin-left: -50px;
17+
-webkit-flex-wrap: wrap;
18+
-ms-flex-wrap: wrap;
19+
flex-wrap: wrap;
20+
}
21+
22+
.c1 > .c2 {
23+
padding-right: 50px;
24+
padding-left: 50px;
25+
}
26+
27+
.c0 {
28+
width: 100%;
29+
margin-right: auto;
30+
margin-left: auto;
31+
padding-right: 50px;
32+
padding-left: 50px;
33+
}
34+
35+
@media (min-width:576px) {
36+
.c0 {
37+
max-width: 540px;
38+
}
39+
}
40+
41+
@media (min-width:768px) {
42+
.c0 {
43+
max-width: 720px;
44+
}
45+
}
46+
47+
@media (min-width:992px) {
48+
.c0 {
49+
max-width: 960px;
50+
}
51+
}
52+
53+
@media (min-width:1200px) {
54+
.c0 {
55+
max-width: 1140px;
56+
}
57+
}
58+
59+
<ThemeProvider
60+
theme={
61+
Object {
62+
"gutterWidth": 100,
63+
}
64+
}
65+
>
66+
<styled.div>
67+
<div
68+
className="c0"
69+
>
70+
<styled.div>
71+
<div
72+
className="c1"
73+
>
74+
<styled.div>
75+
<div
76+
className="c2 c3"
77+
>
78+
Test
79+
</div>
80+
</styled.div>
81+
</div>
82+
</styled.div>
83+
</div>
84+
</styled.div>
85+
</ThemeProvider>
86+
`;

0 commit comments

Comments
 (0)