-
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 #480 from wyne/color-analytics
Permanently enable colors and add analytics
- Loading branch information
Showing
11 changed files
with
103 additions
and
55 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
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 |
---|---|---|
@@ -1,41 +1,94 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import { fireEvent, render, waitFor } from '@testing-library/react-native'; | ||
import { Provider } from 'react-redux'; | ||
|
||
import gamesReducer, { gameDefaults } from '../../../redux/GamesSlice'; | ||
import settingsReducer, { initialState as settingsState } from '../../../redux/SettingsSlice'; | ||
import { useNavigationMock } from '../../../test/test-helpers'; | ||
import { logEvent } from '../../Analytics'; | ||
|
||
import CheckButton from './CheckButton'; | ||
|
||
jest.mock('../../Analytics'); | ||
|
||
const mockStore = () => { | ||
return configureStore({ | ||
reducer: { | ||
settings: settingsReducer, | ||
games: gamesReducer, | ||
}, | ||
preloadedState: { | ||
settings: { | ||
...settingsState, | ||
currentGameId: '123' | ||
}, | ||
games: { | ||
entities: { | ||
'123': { | ||
...gameDefaults, | ||
id: '123', | ||
title: 'Game', | ||
dateCreated: 1, | ||
playerIds: [], | ||
} | ||
}, | ||
ids: ['123'] | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
describe('CheckButton', () => { | ||
const navigation = useNavigationMock(); | ||
|
||
it.skip('should navigate to Game screen when pressed', async () => { | ||
const { getByRole } = render(<CheckButton navigation={navigation} route={{ key: 'Settings', name: 'Settings', params: { source: 'new_game' } }} />); | ||
it('should navigate to Game screen when pressed', async () => { | ||
const store = mockStore(); | ||
|
||
const { getByRole } = render( | ||
<Provider store={store}> | ||
<CheckButton navigation={navigation} route={{ key: 'Settings', name: 'Settings', params: { source: 'new_game' } }} /> | ||
</Provider> | ||
); | ||
|
||
const button = getByRole('button'); | ||
fireEvent.press(button); | ||
|
||
await waitFor(() => { | ||
fireEvent.press(button); | ||
expect(navigation.navigate).toHaveBeenCalledWith('Game'); | ||
}); | ||
}); | ||
}, 10000); | ||
|
||
it('should navigate back a screen when pressed', async () => { | ||
const store = mockStore(); | ||
|
||
const { getByRole } = render( | ||
<Provider store={store}> | ||
<CheckButton navigation={navigation} route={{ key: 'Settings', name: 'Settings', params: { source: 'list_screen' } }} /> | ||
</Provider> | ||
); | ||
|
||
it.skip('should navigate back a screen when pressed', async () => { | ||
const { getByRole } = render(<CheckButton navigation={navigation} route={{ key: 'Settings', name: 'Settings', params: { source: '' } }} />); | ||
const button = getByRole('button'); | ||
fireEvent.press(button); | ||
|
||
await waitFor(() => { | ||
fireEvent.press(button); | ||
expect(navigation.goBack).toHaveBeenCalled(); | ||
expect(navigation.navigate).toHaveBeenCalledWith('List'); | ||
}); | ||
}); | ||
}, 10000); | ||
|
||
it('should log an analytics event when pressed', async () => { | ||
const { getByRole } = render(<CheckButton navigation={navigation} />); | ||
const button = getByRole('button'); | ||
const store = mockStore(); | ||
|
||
const { getByRole } = render( | ||
<Provider store={store}> | ||
<CheckButton navigation={navigation} /> | ||
</Provider> | ||
); | ||
|
||
const button = getByRole('button'); | ||
fireEvent.press(button); | ||
|
||
await waitFor(() => { | ||
expect(logEvent).toHaveBeenCalledWith('save_game'); | ||
expect(logEvent).toHaveBeenCalledWith('save_game', expect.any(Object)); | ||
}); | ||
}); | ||
}, 10000); | ||
}); |
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
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