diff --git a/__tests__/MoreScreen.test.tsx b/__tests__/MoreScreen.test.tsx
index b394e87..694e5a4 100644
--- a/__tests__/MoreScreen.test.tsx
+++ b/__tests__/MoreScreen.test.tsx
@@ -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:yashkamal.bhatia@slu.edu?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(
);
+
+ // 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(
+
+
+
+ );
+
+ 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(
+
+
+
+ );
+
+ // 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(
+
+
+
+ );
+
+ // 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' }]));
});
});
diff --git a/__tests__/__snapshots__/MoreScreen.test.tsx.snap b/__tests__/__snapshots__/MoreScreen.test.tsx.snap
index caed6c5..dce0bd3 100644
--- a/__tests__/__snapshots__/MoreScreen.test.tsx.snap
+++ b/__tests__/__snapshots__/MoreScreen.test.tsx.snap
@@ -581,7 +581,7 @@ exports[`MorePage renders correctly 1`] = `
]
}
>
- Dark Mode
+ Light Mode
= ({ navigation,
// Add a guard check before calling editor.commands.focus()
useEffect(() => {
- if (editor?.commands?.focus) {
+ if (editor?.focus) {
const timeout = setTimeout(() => {
- editor.commands.focus();
+ editor.focus();
}, 500);
return () => clearTimeout(timeout);
}
@@ -84,8 +82,9 @@ const AddNoteScreen: React.FC<{ navigation: any, route: any }> = ({ navigation,
};
const addImageToEditor = (imageUri: string) => {
- const imgTag = ``;
- editor.commands.setContent(editor.getHTML() + imgTag);
+ const imgTag =
+ ``;
+ editor.setContent(editor.getHTML() + imgTag);
};
const addVideoToEditor = async (videoUri: string) => {
@@ -96,7 +95,7 @@ const AddNoteScreen: React.FC<{ navigation: any, route: any }> = ({ navigation,