Skip to content

Commit

Permalink
feat: add screen container component
Browse files Browse the repository at this point in the history
  • Loading branch information
RediaUa committed Dec 9, 2024
1 parent 2a0de62 commit e1d038e
Show file tree
Hide file tree
Showing 12 changed files with 685 additions and 324 deletions.
25 changes: 9 additions & 16 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Text } from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
// components
import { ScreenContainer } from '@core/ui/containers'

export default function App() {
return (
<View style={styles.container}>
<Text>Welcome!</Text>
<StatusBar style="auto" />
</View>
<SafeAreaProvider>
<ScreenContainer>
<Text>Welcome!</Text>
</ScreenContainer>
</SafeAreaProvider>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
2 changes: 1 addition & 1 deletion __tests__ /App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import 'jest-styled-components'
import { render } from '@testing-library/react-native';
import App from '../App';

Expand Down
38 changes: 38 additions & 0 deletions __tests__ /core/ui/containers/ScreenContainer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'jest-styled-components'
import { Text } from 'react-native'
import { render } from '@testing-library/react-native';
import { ScreenContainer } from '@core/ui/containers';

describe('ScreenContainer', () => {
it('renders correctly without scrollable', () => {
const { getByText } = render(
<ScreenContainer scrollable={false}>
<Text>Test Content</Text>
</ScreenContainer>
);

expect(getByText('Test Content')).toBeTruthy();
});

it('renders correctly with scrollable', () => {
const { getByText } = render(
<ScreenContainer scrollable={true}>
<Text>Test Content</Text>
</ScreenContainer>
);

expect(getByText('Test Content')).toBeTruthy();
});

it('applies custom styles correctly', () => {
const customStyle = { backgroundColor: 'red' };
const { getByTestId } = render(
<ScreenContainer style={customStyle}>
<Text>Test Content</Text>
</ScreenContainer>
);

const container = getByTestId('screen-container');
expect(container.props.style).toContainEqual(customStyle);
});
});
4 changes: 1 addition & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ module.exports = {
"./"
],
"alias": {
"@tests": "tests/*",
"@components/*": "src/components/*",
"@utils/*": "src/utils/*"
"@core/*": "src/core/*",
}
}]
]
Expand Down
Loading

0 comments on commit e1d038e

Please sign in to comment.