-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from callstack-internal/data-and-components
[BASE] Add Data and Components
- Loading branch information
Showing
40 changed files
with
1,158 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
WEATHER_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@react-native', | ||
env: { | ||
jest: true, | ||
}, | ||
overrides: [ | ||
{ | ||
// Test files only | ||
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], | ||
extends: ['plugin:testing-library/react'], | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: 'Install dependencies' | ||
description: 'Install dependencies for the project' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Copy .env file | ||
shell: bash | ||
run: cp .env.template .env | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: yarn install --frozen-lockfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
|
||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
branches: ['main'] | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/install | ||
|
||
- name: Run TypeScript | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
run: yarn tsc --noEmit | ||
|
||
- name: Run ESLint | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
run: yarn lint | ||
|
||
- name: Run Unit Tests | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,6 @@ yarn-error.log | |
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# Env | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
module.exports = { | ||
arrowParens: 'avoid', | ||
arrowParens: 'always', | ||
bracketSameLine: true, | ||
bracketSpacing: false, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
semi: true, | ||
tabWidth: 2, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,25 @@ | ||
import {QueryClient, QueryClientProvider} from '@tanstack/react-query'; | ||
import { | ||
DarkTheme, | ||
DefaultTheme, | ||
NavigationContainer, | ||
} from '@react-navigation/native'; | ||
import React from 'react'; | ||
import {StyleSheet, Text, View} from 'react-native'; | ||
import {NavigationContainer} from '@react-navigation/native'; | ||
import {createNativeStackNavigator} from '@react-navigation/native-stack'; | ||
import {useColorScheme} from 'react-native'; | ||
import {RootNavigator} from './src/RootNavigator'; | ||
|
||
function HomeScreen() { | ||
return ( | ||
<View style={styles.screen}> | ||
<Text>Home Screen</Text> | ||
</View> | ||
); | ||
} | ||
|
||
const Stack = createNativeStackNavigator(); | ||
const queryClient = new QueryClient(); | ||
|
||
function App() { | ||
const scheme = useColorScheme(); | ||
|
||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen name="Home" component={HomeScreen} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
<QueryClientProvider client={queryClient}> | ||
<NavigationContainer theme={scheme === 'dark' ? DarkTheme : DefaultTheme}> | ||
<RootNavigator /> | ||
</NavigationContainer> | ||
</QueryClientProvider> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
screen: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
WEATHER_API_KEY: 'test-weather', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
/** | ||
* @format | ||
*/ | ||
|
||
import 'react-native'; | ||
import {render} from '@testing-library/react-native'; | ||
import React from 'react'; | ||
import App from '../App'; | ||
|
||
// Note: import explicitly to use the types shipped with jest. | ||
import {it} from '@jest/globals'; | ||
|
||
// Note: test renderer must be required after react-native. | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders correctly', () => { | ||
renderer.create(<App />); | ||
it('renders correctly', async () => { | ||
render(<App />); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
appId: ${APP_ID} | ||
--- | ||
- launchApp | ||
- assertVisible: 'Weather' | ||
- assertVisible: | ||
id: 'Warsaw' | ||
index: 0 | ||
- tapOn: | ||
id: 'Warsaw' | ||
index: 0 | ||
- assertVisible: 'Humidity' | ||
- assertVisible: 'Pressure' | ||
- assertVisible: 'Wind' | ||
- assertVisible: 'Visibility' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import '@testing-library/react-native/extend-expect'; | ||
import {setupServer} from 'msw/node'; | ||
import {handlers} from './src/mocks/handlers'; | ||
|
||
jest.useFakeTimers(); | ||
|
||
export const server = setupServer(...handlers); | ||
|
||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
module.exports = { | ||
/** @type {import('jest').Config} */ | ||
const config = { | ||
preset: 'react-native', | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!((jest-)?react-native|@react-native/.*|react-navigation|@react-navigation/.*))', | ||
], | ||
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'], | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare module 'react-native-config' { | ||
export interface NativeConfig { | ||
WEATHER_API_KEY?: string; | ||
} | ||
|
||
export const Config: NativeConfig; | ||
export default Config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import {createNativeStackNavigator} from '@react-navigation/native-stack'; | ||
import {RootStackParamList, WeatherStackParamsList} from './types'; | ||
import WeatherList from './screens/WeatherList'; | ||
import WeatherDetails from './screens/WeatherDetails'; | ||
|
||
const Stack = createNativeStackNavigator<RootStackParamList>(); | ||
const WeatherStack = createNativeStackNavigator<WeatherStackParamsList>(); | ||
|
||
function WeatherStackScreen() { | ||
return ( | ||
<WeatherStack.Navigator> | ||
<WeatherStack.Screen | ||
name="WeatherList" | ||
component={WeatherList} | ||
options={{title: 'Weather'}} | ||
/> | ||
<WeatherStack.Screen | ||
name="WeatherDetails" | ||
component={WeatherDetails} | ||
options={{title: 'Details'}} | ||
/> | ||
</WeatherStack.Navigator> | ||
); | ||
} | ||
|
||
export function RootNavigator() { | ||
return ( | ||
<Stack.Navigator> | ||
<Stack.Screen | ||
name="Weather" | ||
component={WeatherStackScreen} | ||
options={{headerShown: false}} | ||
/> | ||
</Stack.Navigator> | ||
); | ||
} |
Oops, something went wrong.