Skip to content

Commit

Permalink
LPD-35824 Implement unity test to check if data-option-reference attr…
Browse files Browse the repository at this point in the history
…ibute is rendered in Single Selection field type
  • Loading branch information
cgmonte authored and brianchandotcom committed Sep 10, 2024
1 parent f9e3b81 commit 3d3c389
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,49 @@ describe('Field Radio', () => {
expect(container).toMatchSnapshot();
});

it('renders option elements with data-option-reference attribute', () => {
const {container} = render(
<RadioWithProvider
{...defaultRadioConfig}
options={[
{
checked: false,
disabled: false,
id: 'id',
inline: false,
label: 'label',
name: 'name',
reference: 'option1Reference',
showLabel: true,
value: 'item',
},
{
checked: false,
disabled: false,
id: 'id',
inline: false,
label: 'label2',
name: 'name',
reference: 'option2Reference',
showLabel: true,
value: 'item2',
},
]}
/>
);

const radioInputElement1 = container.querySelector(
`input[value][type="radio"][data-option-reference="option1Reference"]`
);

const radioInputElement2 = container.querySelector(
`input[value][type="radio"][data-option-reference="option2Reference"]`
);

expect(radioInputElement1).toBeTruthy();
expect(radioInputElement2).toBeTruthy();
});

it('renders no options when options is empty', () => {
const {container} = render(
<RadioWithProvider {...defaultRadioConfig} options={[]} />
Expand Down

0 comments on commit 3d3c389

Please sign in to comment.