Skip to content

Commit 4037a99

Browse files
committed
feat: move native to styled-components/native
1 parent f9b882c commit 4037a99

File tree

9 files changed

+989
-0
lines changed

9 files changed

+989
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import * as React from 'react'
2+
import '@testing-library/jest-native/extend-expect'
3+
import { render, screen } from '@testing-library/react-native'
4+
import { css, ThemeProvider } from '.'
5+
import { scStyledNative as styled } from './scStyled'
6+
7+
const SpaceTheme = ({ children }: { children: React.ReactNode }) => {
8+
return (
9+
<ThemeProvider theme={{ space: { 1: 4, 2: 8 } }}>{children}</ThemeProvider>
10+
)
11+
}
12+
13+
describe('#css', () => {
14+
it('transforms rules', () => {
15+
const Dummy = styled.View`
16+
${css`
17+
margin: 2;
18+
padding: 1;
19+
margin-top: 2px;
20+
`}
21+
`
22+
render(
23+
<SpaceTheme>
24+
<Dummy testID="dummy" />
25+
</SpaceTheme>,
26+
)
27+
28+
const expectedStyle = {
29+
marginBottom: 8,
30+
marginLeft: 8,
31+
marginRight: 8,
32+
marginTop: 2,
33+
paddingBottom: 4,
34+
paddingLeft: 4,
35+
paddingRight: 4,
36+
paddingTop: 4,
37+
}
38+
39+
expect(screen.getByTestId('dummy')).toHaveStyle(expectedStyle)
40+
})
41+
42+
it('transforms multi values', () => {
43+
const Dummy = styled.View`
44+
${css`
45+
margin: 1 2;
46+
`}
47+
`
48+
render(
49+
<SpaceTheme>
50+
<Dummy testID="dummy" />
51+
</SpaceTheme>,
52+
)
53+
expect(screen.getByTestId('dummy')).toHaveStyle({
54+
marginBottom: 4,
55+
marginTop: 4,
56+
marginLeft: 8,
57+
marginRight: 8,
58+
})
59+
})
60+
})

0 commit comments

Comments
 (0)