Skip to content

Commit

Permalink
feat(@clayui/core): LPD-35826 Add unity test to check if props prefix…
Browse files Browse the repository at this point in the history
…ed by "data-" are rendered as attributes in the option element
  • Loading branch information
cgmonte committed Sep 13, 2024
1 parent 75d052d commit 3be3a12
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/clay-core/src/picker/__tests__/BasicRendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import Icon from '@clayui/icon';
import {cleanup, render} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';

import {Option, Picker} from '../../';
Expand Down Expand Up @@ -208,4 +209,22 @@ describe('Picker basic rendering', () => {
expect(selectedValue.getAttribute('aria-expanded')).toBe('false');
expect(selectedValue.getAttribute('tabindex')).toBe('0');
});

it('render option with a custom attribute prefixed by "data-"', () => {
const {getByRole} = render(
<Picker>
<Option data-attribute="data-attribute-value" />
</Picker>
);

const combobox = getByRole('combobox');

userEvent.click(combobox);

const option = getByRole('option');

expect(option.getAttribute('data-attribute')).toBe(
'data-attribute-value'
);
});
});

0 comments on commit 3be3a12

Please sign in to comment.