Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 6d30004

Browse files
committed
Add tests
1 parent 0ee84a9 commit 6d30004

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

packages/chakra-ui-core/src/CGrid/test/CGrid.test.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { CGrid } from '..'
1+
import { CGrid, CGridItem } from '..'
22
import { render } from '@/tests/test-utils'
33

44
const renderComponent = (props) => {
55
const inlineAttrs = (props && props.inlineAttrs) || ''
66
const base = {
7-
components: { CGrid },
7+
components: { CGrid, CGridItem },
88
template: `<CGrid ${inlineAttrs}>Grid Me</CGrid>`,
99
...props
1010
}
@@ -23,3 +23,25 @@ it('should change gap', () => {
2323

2424
expect(asFragment()).toMatchSnapshot()
2525
})
26+
27+
it('should offset columns', () => {
28+
const inlineAttrs = 'col-start="4" col-end="6"'
29+
const { asFragment } = renderComponent({
30+
template: `
31+
<CGrid w="600px" template-columns="repeat(5, 1fr)" gap="6">
32+
<CGridItem ${inlineAttrs}>I'm in a grid item</CGridItem>
33+
</CGrid>`
34+
})
35+
expect(asFragment()).toMatchSnapshot()
36+
})
37+
38+
it('should span columns', () => {
39+
const inlineAttrs = 'col-span="2"'
40+
const { asFragment } = renderComponent({
41+
template: `
42+
<CGrid w="600px" template-columns="repeat(5, 1fr)" gap="6">
43+
<CGridItem ${inlineAttrs}>I'm in a grid item</CGridItem>
44+
</CGrid>`
45+
})
46+
expect(asFragment()).toMatchSnapshot()
47+
})

packages/chakra-ui-core/src/CGrid/test/__snapshots__/CGrid.test.js.snap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ exports[`should change gap 1`] = `
1111
</DocumentFragment>
1212
`;
1313

14+
exports[`should offset columns 1`] = `
15+
<DocumentFragment>
16+
<div
17+
class="css-12kxrxg"
18+
data-chakra-component="CGrid"
19+
>
20+
<div
21+
class="css-1i8ejg0"
22+
data-chakra-component="CGridItem"
23+
>
24+
I'm in a grid item
25+
</div>
26+
</div>
27+
</DocumentFragment>
28+
`;
29+
1430
exports[`should render correctly 1`] = `
1531
<DocumentFragment>
1632
<div
@@ -21,3 +37,19 @@ exports[`should render correctly 1`] = `
2137
</div>
2238
</DocumentFragment>
2339
`;
40+
41+
exports[`should span columns 1`] = `
42+
<DocumentFragment>
43+
<div
44+
class="css-12kxrxg"
45+
data-chakra-component="CGrid"
46+
>
47+
<div
48+
class="css-tuh9u2"
49+
data-chakra-component="CGridItem"
50+
>
51+
I'm in a grid item
52+
</div>
53+
</div>
54+
</DocumentFragment>
55+
`;

0 commit comments

Comments
 (0)