Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
test: use fixture files
Browse files Browse the repository at this point in the history
  • Loading branch information
z0al committed Nov 29, 2020
1 parent e66b582 commit b7a20d9
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 1,358 deletions.
31 changes: 31 additions & 0 deletions src/__tests__/__fixtures__/complex/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import styled from '../../../../build/module/macro';
import { Text, Pressable, SafeAreaView } from 'react-native';
import { useWindowVariant } from 'react-native-styled.macro/lib';

export default function App() {
const variants = useWindowVariant();

return (
<SafeAreaView {...styled(['flex-1', 'items-center'])}>
<Pressable
{...styled(
[
'mx-2',
'border',
'rounded-lg',
'border-indigo-600',
'bg-indigo-600',
'sm:bg-green-600',
'md:bg-teal-600',
'lg:bg-yellow-600',
'xl:bg-orange-600',
],
variants
)}
>
<Text {...styled(['text-base', 'text-white'])}>Press me</Text>
</Pressable>
</SafeAreaView>
);
}
87 changes: 87 additions & 0 deletions src/__tests__/__fixtures__/complex/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { rem as _rem3 } from 'react-native-styled.macro/build/module/utils/rem';
import { rem as _rem2 } from 'react-native-styled.macro/build/module/utils/rem';
import { rem as _rem } from 'react-native-styled.macro/build/module/utils/rem';
import { StyleSheet as _StyleSheet } from 'react-native';
import { select as _select } from 'react-native-styled.macro/build/module/utils/select';

const _styles = _StyleSheet.create({
_default: {
flexGrow: 1,
flexShrink: 1,
flexBasis: '0%',
alignItems: 'center',
},
_default2: {
marginHorizontal: _rem(0.5),
borderWidth: 1,
borderRadius: _rem2(0.5),
borderColor: '#5a67d8',
backgroundColor: '#5a67d8',
},
_sm: {
backgroundColor: '#38a169',
},
_md: {
backgroundColor: '#319795',
},
_lg: {
backgroundColor: '#d69e2e',
},
_xl: {
backgroundColor: '#dd6b20',
},
_default3: {
fontSize: _rem3(1),
color: 'white',
},
});

import React from 'react';
import { Text, Pressable, SafeAreaView } from 'react-native';
import { useWindowVariant } from 'react-native-styled.macro/lib';
export default function App() {
const variants = useWindowVariant();
return (
<SafeAreaView
{...{
style: [_styles._default],
}}
>
<Pressable
{..._select(
[
{
variant: 'default',
style: _styles._default2,
},
{
variant: 'sm',
style: _styles._sm,
},
{
variant: 'md',
style: _styles._md,
},
{
variant: 'lg',
style: _styles._lg,
},
{
variant: 'xl',
style: _styles._xl,
},
],
variants
)}
>
<Text
{...{
style: [_styles._default3],
}}
>
Press me
</Text>
</Pressable>
</SafeAreaView>
);
}
3 changes: 3 additions & 0 deletions src/__tests__/__fixtures__/simple/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import styled from '../../../../build/module/macro';

console.log(styled(['bg-white', 'selectable']));
12 changes: 12 additions & 0 deletions src/__tests__/__fixtures__/simple/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { StyleSheet as _StyleSheet } from 'react-native';

const _styles = _StyleSheet.create({
_default: {
backgroundColor: 'white',
},
});

console.log({
selectable: true,
style: [_styles._default],
});
9 changes: 9 additions & 0 deletions src/__tests__/__fixtures__/with-variables/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from '../../../../build/module/macro';

const bgWhite = 'bg-white';

const buttonStyle = [bgWhite, 'text-black'];
const inputStyle = [bgWhite, 'text-black'];

console.log(styled(buttonStyle));
console.log(styled(inputStyle));
22 changes: 22 additions & 0 deletions src/__tests__/__fixtures__/with-variables/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { StyleSheet as _StyleSheet } from 'react-native';

const _styles = _StyleSheet.create({
_default: {
backgroundColor: 'white',
color: 'black',
},
_default2: {
backgroundColor: 'white',
color: 'black',
},
});

const bgWhite = 'bg-white';
const buttonStyle = [bgWhite, 'text-black'];
const inputStyle = [bgWhite, 'text-black'];
console.log({
style: [_styles._default],
});
console.log({
style: [_styles._default2],
});
10 changes: 10 additions & 0 deletions src/__tests__/__fixtures__/with-variants/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from '../../../../build/module/macro';

console.log(
styled(
['bg-white', 'selectable', 'web:not-selectable', 'dark:bg-black'],
{
dark: false,
}
)
);
36 changes: 36 additions & 0 deletions src/__tests__/__fixtures__/with-variants/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { StyleSheet as _StyleSheet } from 'react-native';
import { select as _select } from 'react-native-styled.macro/build/module/utils/select';

const _styles = _StyleSheet.create({
_default: {
backgroundColor: 'white',
},
_web: undefined,
_dark: {
backgroundColor: 'black',
},
});

console.log(
_select(
[
{
variant: 'default',
selectable: true,
style: _styles._default,
},
{
variant: 'web',
selectable: false,
style: _styles._web,
},
{
variant: 'dark',
style: _styles._dark,
},
],
{
dark: false,
}
)
);
Loading

0 comments on commit b7a20d9

Please sign in to comment.