-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stephen Hanson
committed
Aug 22, 2024
1 parent
d1a8dbc
commit 4d501b5
Showing
14 changed files
with
364 additions
and
172 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
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,40 @@ | ||
import { execSync } from 'child_process'; | ||
|
||
// copies files over from a sample app generated with `bin/belt.js` | ||
// See CONTRIBUTING.md for more info | ||
function run() { | ||
const appDir = process.argv[2]; | ||
|
||
if (!appDir || appDir.includes('builds')) { | ||
console.error('Please provide an app directory, relative to `builds`'); | ||
console.error('Usage: node bin/sync-from-app.js MyApp --dry-run'); | ||
process.exit(1); | ||
} | ||
|
||
const excludes = [ | ||
'node_modules', | ||
'.cache', | ||
'.expo', | ||
'.vscode', | ||
'assets', | ||
'.git', | ||
'.gitignore', | ||
]; | ||
|
||
const excludesStr = excludes.map((e) => `--exclude ${e}`).join(' '); | ||
|
||
// provide additional flags, eg. --dry-run | ||
const flags = `-avp ${process.argv[3] || ''}`; | ||
|
||
const command = `rsync ${flags} ${excludesStr} builds/${appDir}/ templates/boilerplate/`; | ||
console.log(command); | ||
execSync(command, { | ||
stdio: 'inherit', | ||
}); | ||
|
||
console.log( | ||
"\n\n🎉 Success! Ensure that all files have copied over correctly, remove any unwanted modifications (eg. app.json, package.json, etc), and manually remove any files that need to be deleted (these don't sync)", | ||
); | ||
} | ||
|
||
run(); |
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
58 changes: 58 additions & 0 deletions
58
templates/boilerplate/src/__tests__/App.integration.test.tsx
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,58 @@ | ||
import { screen, userEvent } from '@testing-library/react-native'; | ||
|
||
import mock from 'src/test/mock'; | ||
import { renderApplication } from 'src/test/render'; | ||
import { GithubProjectsResponse } from 'src/util/api/api'; | ||
|
||
// Testing philosophy: | ||
// - Tests that render the entire application with `renderApplication` go in the | ||
// top level `src/__tests__` directory and are named with `mytest.integration.test.tsx`. | ||
// These are ideal for when you need to test flows that include navigation between screens | ||
// - Tests that render a single screen or component are colocated in | ||
// `__tests__/MyComponent.test.tsx`. These call `render` and are not able to | ||
// navigate between screens, since the Navigator is not mounted | ||
test('renders app, can navigate between screens', async () => { | ||
jest.useFakeTimers(); | ||
|
||
const mocks = [mockGitHubProjects()]; | ||
|
||
// load the app on the Home screen | ||
renderApplication({ mocks }); | ||
expect( | ||
await screen.findByRole('header', { name: /Welcome to your new app/ }), | ||
).toBeDefined(); | ||
|
||
// go to About tab | ||
await userEvent.press(screen.getByRole('button', { name: /About/ })); | ||
expect( | ||
await screen.findByRole('header', { name: 'Open Source' }), | ||
).toBeDefined(); | ||
|
||
// expect GitHub project loaded via API | ||
expect(await screen.findByText(/Belt is a CLI/)).toBeDefined(); | ||
}); | ||
|
||
// TODO: sample data, remove | ||
// creates a mock for a GET request to the GitHub projects API. | ||
// Pass this mock to `render` or `renderApplication` to register it with MSW. | ||
// Recommended to place these mocks in a central location like `src/test/mocks` | ||
function mockGitHubProjects() { | ||
return mock.get<GithubProjectsResponse, null>( | ||
'https://github-projects-api.vercel.app/api/projects', | ||
{ | ||
response: { | ||
projects: [ | ||
{ | ||
id: 635980144, | ||
name: 'belt', | ||
description: | ||
'Belt is a CLI for starting a new React Native Expo app and will even keep your pants secure as you continue development.', | ||
url: 'https://github.com/thoughtbot/belt', | ||
stars: 8, | ||
forks: 0, | ||
}, | ||
], | ||
}, | ||
}, | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
28 changes: 5 additions & 23 deletions
28
templates/boilerplate/src/screens/HomeScreen/HomeScreen.tsx
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,30 +1,12 @@ | ||
import { useNavigation } from '@react-navigation/native'; | ||
import { StatusBar } from 'expo-status-bar'; | ||
import { Button, StyleSheet, Text, View } from 'react-native'; | ||
import { HomeScreenProp } from 'src/navigators/navigatorTypes'; | ||
import Screen from 'src/components/Screen'; | ||
import HomeScreenContent from './HomeScreenContent'; | ||
|
||
export default function HomeScreen() { | ||
const navigation = useNavigation<HomeScreenProp['navigation']>(); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text>Open up App.tsx to start working on your app!</Text> | ||
<Button | ||
title="Go to information screen" | ||
onPress={() => | ||
navigation.navigate('Information', { greeting: 'Hello 👋' }) | ||
} | ||
/> | ||
<Screen> | ||
<HomeScreenContent /> | ||
<StatusBar style="auto" /> | ||
</View> | ||
</Screen> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); |
Oops, something went wrong.