forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #58 from suisin-deriv/suisin/93479/test_case_for_j…
…urisdiction_clickable_description Suisin/chore: test case for jurisdiction clickable description
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...fd/src/Containers/jurisdiction-modal/__test__/jurisdiction-clickable-description.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,39 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import JurisdictionClickableDescription from '../jurisdiction-clickable-description'; | ||
|
||
describe('JurisdictionClickableDescription', () => { | ||
type TClickableDescription = { text: string; type: 'link' | 'text' }; | ||
type TMockProps = { | ||
clickable_description: TClickableDescription[]; | ||
toggleCardFlip: jest.Mock; | ||
}; | ||
|
||
const mock_props: TMockProps = { | ||
clickable_description: [ | ||
{ | ||
text: 'Click here', | ||
type: 'link', | ||
}, | ||
{ | ||
text: 'to learn more about the documents required for verification.', | ||
type: 'text', | ||
}, | ||
], | ||
toggleCardFlip: jest.fn(), | ||
}; | ||
|
||
it('should render JurisdictionClickableDescription', () => { | ||
render(<JurisdictionClickableDescription {...mock_props} />); | ||
const container = screen.getByTestId('dt_jurisdiction_clickable_description'); | ||
expect(container).toHaveClass('cfd-card-clickable-description-link'); | ||
expect(screen.getByText('Click here')).toBeInTheDocument(); | ||
expect(screen.getByText('to learn more about the documents required for verification.')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call toggleCardFlip when link is clicked', () => { | ||
render(<JurisdictionClickableDescription {...mock_props} />); | ||
screen.getByText('Click here').click(); | ||
expect(mock_props.toggleCardFlip).toHaveBeenCalled(); | ||
}); | ||
}); |
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