-
Notifications
You must be signed in to change notification settings - Fork 6
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 #195 from oss-slu/issue-193
Update The Theme Text Dynamically (issue #193)
- Loading branch information
Showing
6 changed files
with
21,047 additions
and
1,974 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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { fireEvent, render } from '@testing-library/react-native'; | ||
import moxios from 'moxios'; | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react-native'; | ||
import { Linking } from 'react-native'; | ||
import { Provider } from 'react-redux'; | ||
import configureStore from 'redux-mock-store'; | ||
import MorePage from '../lib/screens/MorePage'; | ||
import moxios from 'moxios'; | ||
import { User } from '../lib/models/user_class'; | ||
import { Linking } from 'react-native'; | ||
import { useTheme } from '../lib/components/ThemeProvider'; | ||
import MorePage from '../lib/screens/MorePage'; | ||
|
||
// Create a mock Redux store | ||
const mockStore = configureStore([]); | ||
|
@@ -106,14 +105,69 @@ describe('MorePage', () => { | |
"mailto:[email protected]?subject=Bug%20Report%20on%20'Where's%20Religion%3F'&body=Please%20provide%20details%20of%20your%20issue%20you%20are%20facing%20here." | ||
); | ||
}); | ||
it('renders the "Logout" button', () => { | ||
const { getByText } = render( | ||
|
||
it('displays correct theme text based on isDarkmode value', () => { | ||
const { getByText, rerender } = render( | ||
<Provider store={store}> | ||
<MorePage /> | ||
</Provider> | ||
); | ||
|
||
// Check Light Mode text when isDarkmode is false | ||
expect(getByText('Light Mode')).toBeTruthy(); | ||
|
||
// Update isDarkmode to true & renderer | ||
useTheme.mockReturnValueOnce({ | ||
theme: { | ||
primaryColor: '#ffffff', | ||
text: '#ffffff', | ||
secondaryColor: '#f0f0f0', | ||
logout: '#ff0000', | ||
logoutText: '#ffffff', | ||
}, | ||
isDarkmode: true, | ||
toggleDarkmode: jest.fn(), | ||
}); | ||
rerender( | ||
<Provider store={store}> | ||
<MorePage /> | ||
</Provider> | ||
); | ||
|
||
expect(getByText('Dark Mode')).toBeTruthy(); | ||
}); | ||
|
||
// Check if the "Logout" button is rendered | ||
expect(getByText('Logout')).toBeTruthy(); | ||
it('displays correct text color for theme text', () => { | ||
const { getByText, rerender } = render( | ||
<Provider store={store}> | ||
<MorePage /> | ||
</Provider> | ||
); | ||
|
||
// Check that Light Mode text is black when isDarkmode is false | ||
const lightModeText = getByText('Light Mode'); | ||
expect(lightModeText.props.style).toEqual(expect.arrayContaining([{ color: '#000000' }])); | ||
|
||
// Update isDarkmode to true and rerender | ||
useTheme.mockReturnValueOnce({ | ||
theme: { | ||
primaryColor: '#ffffff', | ||
text: '#ffffff', | ||
secondaryColor: '#f0f0f0', | ||
logout: '#ff0000', | ||
logoutText: '#ffffff', | ||
}, | ||
isDarkmode: true, | ||
toggleDarkmode: jest.fn(), | ||
}); | ||
rerender( | ||
<Provider store={store}> | ||
<MorePage /> | ||
</Provider> | ||
); | ||
|
||
// Check that Dark Mode text is white when isDarkmode is true | ||
const darkModeText = getByText('Dark Mode'); | ||
expect(darkModeText.props.style).toEqual(expect.arrayContaining([{ color: '#ffffff' }])); | ||
}); | ||
}); |
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
Oops, something went wrong.