-
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 #173 from oss-slu/170-dark-mode
170 dark mode
- Loading branch information
Showing
3 changed files
with
81 additions
and
54 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 |
---|---|---|
@@ -1,25 +1,37 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react-native'; | ||
import { render, fireEvent, waitFor } from '@testing-library/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'; | ||
|
||
// Mock the ThemeProvider | ||
// Create a mock Redux store | ||
const mockStore = configureStore([]); | ||
const store = mockStore({ | ||
navigation: { | ||
navState: 'more', // Add mock navigation state if needed | ||
}, | ||
theme: { | ||
darkMode: false, // Add mock theme state if needed | ||
}, | ||
}); | ||
|
||
// Mock the ThemeProvider with spies | ||
jest.mock('../lib/components/ThemeProvider', () => ({ | ||
useTheme: () => ({ | ||
useTheme: jest.fn(() => ({ | ||
theme: { | ||
primaryColor: '#ffffff', | ||
text: '#000000', | ||
secondaryColor: '#f0f0f0', | ||
logout: '#ff0000', | ||
logoutText: '#ffffff', | ||
}, | ||
isDarkmode: false, // Mock initial state for dark mode | ||
isDarkmode: false, // Initial value of isDarkmode | ||
toggleDarkmode: jest.fn(), // Mock the toggleDarkmode function | ||
}), | ||
})), | ||
})); | ||
|
||
// Mock the User class | ||
|
@@ -33,17 +45,6 @@ jest.mock('../lib/models/user_class', () => { | |
}; | ||
}); | ||
|
||
// Create a mock Redux store | ||
const mockStore = configureStore([]); | ||
const store = mockStore({ | ||
navigation: { | ||
navState: 'more', // Add mock navigation state if needed | ||
}, | ||
theme: { | ||
darkMode: false, // Add mock theme state if needed | ||
}, | ||
}); | ||
|
||
beforeAll(() => { | ||
// Suppress console logs during tests | ||
jest.spyOn(console, 'log').mockImplementation(() => {}); | ||
|
@@ -105,4 +106,14 @@ 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( | ||
<Provider store={store}> | ||
<MorePage /> | ||
</Provider> | ||
); | ||
|
||
// Check if the "Logout" button is rendered | ||
expect(getByText('Logout')).toBeTruthy(); | ||
}); | ||
}); |
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