-
Notifications
You must be signed in to change notification settings - Fork 10
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 #286 from shafin-deriv/shafin/DAPI-462/feat--api-r…
…egistration-flow [DAPI] feat: new app dashboard and app registration flow
- Loading branch information
Showing
33 changed files
with
1,438 additions
and
12 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
src/components/CustomRadioButton/__tests__/CustomRadioButton.test.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,55 @@ | ||
import React from 'react'; | ||
import { cleanup, render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import CustomRadioButton from '..'; | ||
|
||
const onChange = jest.fn(); | ||
|
||
describe('CustomRadioButton', () => { | ||
const renderRadioButton = ({ checked }) => { | ||
render( | ||
<CustomRadioButton | ||
id='test_id' | ||
name='test_name' | ||
value='test_value' | ||
checked={checked} | ||
onChange={onChange} | ||
> | ||
<label htmlFor='test_id'>this is a test label</label> | ||
</CustomRadioButton>, | ||
); | ||
}; | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); | ||
|
||
it('should render the radio button', () => { | ||
renderRadioButton({ checked: true }); | ||
const label = screen.getByText('this is a test label'); | ||
expect(label).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the radio button with checked icon', () => { | ||
renderRadioButton({ checked: true }); | ||
const imgElement = screen.getByRole('img'); | ||
expect(imgElement).toBeInTheDocument(); | ||
expect(imgElement).toHaveAttribute('src', '/img/circle_dot_caption_fill.svg'); | ||
}); | ||
|
||
it('should render the radio button with unchecked icon', () => { | ||
renderRadioButton({ checked: false }); | ||
const imgElement = screen.getByRole('img'); | ||
expect(imgElement).toBeInTheDocument(); | ||
expect(imgElement).toHaveAttribute('src', '/img/circle_dot_caption_bold.svg'); | ||
}); | ||
|
||
it('should fire the onChange event when clicking the button', async () => { | ||
renderRadioButton({ checked: false }); | ||
const radio_button = screen.getByRole<HTMLInputElement>('radio', { | ||
name: 'this is a test label', | ||
}); | ||
await userEvent.click(radio_button); | ||
expect(onChange).toBeCalled(); | ||
}); | ||
}); |
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,30 @@ | ||
.custom_radio { | ||
position: relative; | ||
|
||
input { | ||
opacity: 0; | ||
position: absolute; | ||
top: 8px; | ||
} | ||
|
||
label { | ||
display: flex; | ||
align-items: baseline; | ||
cursor: pointer; | ||
} | ||
|
||
&__icon { | ||
position: relative; | ||
margin-inline-end: 8px; | ||
top: 6px; | ||
|
||
img { | ||
width: 24px; | ||
height: 24px; | ||
|
||
@media (max-width: 767px) { | ||
width: 48px; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.