-
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.
- Loading branch information
1 parent
e55c7cf
commit da665d2
Showing
12 changed files
with
85 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import { render, screen } from 'test'; | ||
|
||
import { config } from '../config'; | ||
|
||
describe('config object', () => { | ||
it('should have a textSearch property with a page view that renders correctly', () => { | ||
const Page = config.textSearch.page; | ||
|
||
render(<Page />); | ||
|
||
expect(screen.getByText('Text Search')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should have an imageSearch property with a page view that renders correctly', () => { | ||
const Page = config.imageSearch.page; | ||
|
||
render(<Page />); | ||
|
||
expect(screen.getByText('Image Search')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should have a videoSearch property with a page view that renders correctly', () => { | ||
const Page = config.videoSearch.page; | ||
|
||
render(<Page />); | ||
|
||
expect(screen.getByText('Video Search')).toBeInTheDocument(); | ||
}); | ||
}); |
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,36 @@ | ||
import * as ReactRouterDom from 'react-router-dom'; | ||
|
||
import { renderHook } from 'test'; | ||
|
||
import { useSearchType } from '../useSearchType'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useParams: jest.fn(), | ||
})); | ||
|
||
describe('useSearchType', () => { | ||
it('should return the searchType from URL parameters if it exists in config', () => { | ||
jest.spyOn(ReactRouterDom, 'useParams').mockReturnValue({ searchType: 'imageSearch' }); | ||
|
||
const { result } = renderHook(() => useSearchType()); | ||
|
||
expect(result.current).toBe('imageSearch'); | ||
}); | ||
|
||
it('should return "textSearch" if the searchType from URL parameters does not exist in config', () => { | ||
jest.spyOn(ReactRouterDom, 'useParams').mockReturnValue({ searchType: 'randomSearch' }); | ||
|
||
const { result } = renderHook(() => useSearchType()); | ||
|
||
expect(result.current).toBe('textSearch'); | ||
}); | ||
|
||
it('should return "textSearch" if no searchType is provided in URL parameters', () => { | ||
jest.spyOn(ReactRouterDom, 'useParams').mockReturnValue({}); | ||
|
||
const { result } = renderHook(() => useSearchType()); | ||
|
||
expect(result.current).toBe('textSearch'); | ||
}); | ||
}); |
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