-
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 #165 from oss-slu/161-search-published-entries
Fixes 161 search published entries
- Loading branch information
Showing
4 changed files
with
116 additions
and
9 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,52 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react-native'; | ||
import { Alert } from 'react-native'; | ||
import AddNoteScreen from '../lib/screens/AddNoteScreen'; | ||
import * as Location from 'expo-location'; | ||
import HomeScreen from '../lib/screens/HomeScreen'; | ||
|
||
// Mock external dependencies | ||
jest.mock('../lib/components/ThemeProvider', () => ({ | ||
useTheme: () => ({ | ||
theme: 'mockedTheme', // Provide a mocked theme object | ||
}), | ||
})); | ||
|
||
// Mock expo-location module with TypeScript type support | ||
jest.mock('expo-location', () => ({ | ||
getForegroundPermissionsAsync: jest.fn(), | ||
requestForegroundPermissionsAsync: jest.fn(), | ||
getCurrentPositionAsync: jest.fn(), | ||
})); | ||
|
||
// Mock API calls directly | ||
const mockWriteNewNote = jest.fn(); | ||
jest.mock('../lib/utils/api_calls', () => ({ | ||
writeNewNote: mockWriteNewNote, | ||
})); | ||
|
||
beforeEach(() => { | ||
// Clear mocks before each test | ||
jest.clearAllMocks(); | ||
|
||
// Mock console methods to avoid unnecessary log outputs in tests | ||
jest.spyOn(console, 'log').mockImplementation(() => {}); | ||
jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
// Restore the original console methods | ||
console.log.mockRestore(); | ||
console.error.mockRestore(); | ||
}); | ||
|
||
describe('AddNoteScreen', () => { | ||
it('renders without crashing', () => { | ||
const routeMock = { params: { untitledNumber: 1 } }; | ||
const { getByTestId } = render(<HomeScreen route={routeMock as any} />); | ||
|
||
// Check if the RichEditor is rendered | ||
expect(getByTestId('searchBar')).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
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