-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEQ] P2P-V2 Close header test (#13656)
* chore: removed responsive root * chore: reverted old changes * chore: added test cases for close header * chore: added test cases for close header
- Loading branch information
1 parent
57d7c7e
commit 0505cce
Showing
2 changed files
with
38 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
packages/p2p-v2/src/components/CloseHeader/__tests__/CloseHeader.spec.tsx
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,33 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import CloseHeader from '../CloseHeader'; | ||
|
||
const mockUseDevice = { | ||
isMobile: false, | ||
}; | ||
|
||
jest.mock('@/hooks/useDevice', () => ({ | ||
__esModule: true, | ||
default: jest.fn(() => mockUseDevice), | ||
})); | ||
let windowHistoryBackSpy: jest.SpyInstance<void, []>; | ||
|
||
describe('CloseHeader', () => { | ||
it('should navigate back when cross icon is clicked', () => { | ||
windowHistoryBackSpy = jest.spyOn(window.history, 'back'); | ||
render(<CloseHeader />); | ||
const crossIcon = screen.getByTestId('dt_p2p_v2_close_header_close_icon'); | ||
userEvent.click(crossIcon); | ||
expect(windowHistoryBackSpy).toBeCalled(); | ||
}); | ||
it('should render the correct header title on desktop', () => { | ||
render(<CloseHeader />); | ||
expect(screen.queryByText('Cashier')).toBeInTheDocument(); | ||
}); | ||
it('should render the correct header title on mobile', () => { | ||
mockUseDevice.isMobile = true; | ||
render(<CloseHeader />); | ||
expect(screen.queryByText('Deriv P2P')).toBeInTheDocument(); | ||
}); | ||
}); |