Skip to content

Commit

Permalink
test(AILabel): update tests to use AILabel
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Jun 18, 2024
1 parent ea5ec5b commit 841bda7
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import Checkbox from '../Checkbox';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -205,7 +205,7 @@ describe('Checkbox', () => {
defaultChecked
labelText="Checkbox label"
id="checkbox-label-1"
slug={<Slug />}
slug={<AILabel />}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import CheckboxGroup from '../CheckboxGroup';
import Checkbox from '../Checkbox/Checkbox';
import { render, screen } from '@testing-library/react';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -155,7 +155,7 @@ describe('CheckboxGroup', () => {
<CheckboxGroup
className="some-class"
legendText="Checkbox heading"
slug={<Slug />}
slug={<AILabel />}
/>
);

Expand Down
6 changes: 4 additions & 2 deletions packages/react/src/components/ComboBox/ComboBox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import ComboBox from '../ComboBox';
import { act } from 'react';

import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const findInputNode = () => screen.getByRole('combobox');
const openMenu = async () => {
Expand Down Expand Up @@ -146,7 +146,9 @@ describe('ComboBox', () => {
});

it('should respect slug prop', async () => {
const { container } = render(<ComboBox {...mockProps} slug={<Slug />} />);
const { container } = render(
<ComboBox {...mockProps} slug={<AILabel />} />
);
await waitForPosition();
expect(container.firstChild).toHaveClass(
`${prefix}--list-box__wrapper--slug`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ComposedModal, { ModalBody } from './ComposedModal';
import { ModalHeader } from './ModalHeader';
import { ModalFooter } from './ModalFooter';
import { TextInput } from '../../';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -235,7 +235,7 @@ describe('ComposedModal', () => {

it('should respect slug prop', () => {
const { container } = render(
<ComposedModal open slug={<Slug />}>
<ComposedModal open slug={<AILabel />}>
<ModalHeader>Modal header</ModalHeader>
<ModalBody>This is the modal body content</ModalBody>
<ModalFooter
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/DatePicker/DatePicker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import DatePicker from './DatePicker';
import DatePickerInput from '../DatePickerInput';
import { render, screen, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -203,7 +203,7 @@ describe('DatePicker', () => {
placeholder="mm/dd/yyyy"
labelText="Date Picker label"
data-testid="input-value"
slug={<Slug />}
slug={<AILabel />}
/>
);

Expand Down
6 changes: 4 additions & 2 deletions packages/react/src/components/Dropdown/Dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../ListBox/test-helpers';
import Dropdown from '../Dropdown';
import DropdownSkeleton from '../Dropdown/Dropdown.Skeleton';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -192,7 +192,9 @@ describe('Dropdown', () => {
});

it('should respect slug prop', () => {
const { container } = render(<Dropdown {...mockProps} slug={<Slug />} />);
const { container } = render(
<Dropdown {...mockProps} slug={<AILabel />} />
);
expect(container.firstChild).toHaveClass(
`${prefix}--list-box__wrapper--slug`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Modal/Modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import userEvent from '@testing-library/user-event';

import Modal from './Modal';
import TextInput from '../TextInput';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -374,7 +374,7 @@ describe('Modal', () => {
danger
primaryButtonText="Danger button text"
data-testid="modal-5"
slug={<Slug />}
slug={<AILabel />}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
generateItems,
generateGenericItem,
} from '../../ListBox/test-helpers';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -153,7 +153,7 @@ describe('FilterableMultiSelect', () => {

it('should respect slug prop', () => {
const { container } = render(
<FilterableMultiSelect {...mockProps} slug={<Slug />} />
<FilterableMultiSelect {...mockProps} slug={<AILabel />} />
);
expect(container.firstChild).toHaveClass(
`${prefix}--list-box__wrapper--slug`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React from 'react';
import MultiSelect from '../';
import { generateItems, generateGenericItem } from '../../ListBox/test-helpers';
import userEvent from '@testing-library/user-event';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -574,7 +574,7 @@ describe('MultiSelect', () => {
const items = generateItems(4, generateGenericItem);
const label = 'test-label';
const { container } = render(
<MultiSelect id="test" label={label} items={items} slug={<Slug />} />
<MultiSelect id="test" label={label} items={items} slug={<AILabel />} />
);
expect(container.firstChild).toHaveClass(
`${prefix}--list-box__wrapper--slug`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { NumberInput } from '../NumberInput';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

function translateWithId(id) {
if (id === 'increment.number') {
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('NumberInput', () => {
});

it('should respect slug prop', () => {
render(<NumberInput label="test-label" id="test" slug={<Slug />} />);
render(<NumberInput label="test-label" id="test" slug={<AILabel />} />);

expect(
screen.getByRole('button', { name: 'AI - Show information' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import RadioButton from '../RadioButton';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -142,7 +142,7 @@ describe('RadioButton', () => {
name="test-name"
value="test-value"
labelText="test-label"
slug={<Slug />}
slug={<AILabel />}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import userEvent from '@testing-library/user-event';
import React from 'react';
import RadioButtonGroup from './RadioButtonGroup';
import RadioButton from '../RadioButton';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -216,7 +216,7 @@ describe('RadioButtonGroup', () => {

it('should respect slug prop', () => {
const { container } = render(
<RadioButtonGroup slug={<Slug />} name="test" legendText="test">
<RadioButtonGroup slug={<AILabel />} name="test" legendText="test">
<RadioButton labelText="test-1" value={1} />
<RadioButton labelText="test-0" value={0} />
</RadioButtonGroup>
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Select/__tests__/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SelectItem from '../../SelectItem';
import SelectSkeleton from '../../Select/Select.Skeleton';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -243,7 +243,7 @@ describe('Select', () => {

it('should respect slug prop', () => {
const { container } = render(
<Select id="select" labelText="Select" slug={<Slug />} />
<Select id="select" labelText="Select" slug={<AILabel />} />
);

expect(container.firstChild.firstChild).toHaveClass(
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Tag/Tag-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { render, screen } from '@testing-library/react';
import React from 'react';
import Tag from './';
import DismissibleTag from './DismissibleTag';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

describe('Tag', () => {
describe('automated accessibility testing', () => {
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('Tag', () => {
});

it('should respect slug prop', () => {
render(<Tag type="red" slug={<Slug />} />);
render(<Tag type="red" slug={<AILabel />} />);

expect(
screen.getByRole('button', { name: 'AI - Show information' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TextArea from '../TextArea';
import userEvent from '@testing-library/user-event';
import { fireEvent, waitFor } from '@testing-library/react';
import { render, screen, createEvent } from '@testing-library/react';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -197,7 +197,11 @@ describe('TextArea', () => {

it('should respect slug prop', () => {
render(
<TextArea id="textarea-1" labelText="TextArea label" slug={<Slug />} />
<TextArea
id="textarea-1"
labelText="TextArea label"
slug={<AILabel />}
/>
);
expect(
screen.getByRole('button', { name: 'AI - Show information' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import TextInput from '../TextInput';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { Slug } from '../../Slug';
import { AILabel } from '../../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -228,7 +228,11 @@ describe('TextInput', () => {

it('should respect slug prop', () => {
render(
<TextInput id="textarea-1" labelText="TextArea label" slug={<Slug />} />
<TextInput
id="textarea-1"
labelText="TextArea label"
slug={<AILabel />}
/>
);
expect(
screen.getByRole('button', { name: 'AI - Show information' })
Expand Down
14 changes: 9 additions & 5 deletions packages/react/src/components/Tile/Tile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import Link from '../Link';
import { Add } from '@carbon/icons-react';
import { Slug } from '../Slug';
import { AILabel } from '../AILabel';

const prefix = 'cds';

Expand Down Expand Up @@ -49,7 +49,7 @@ describe('Tile', () => {
});

it('should respect slug prop', () => {
render(<Tile slug={<Slug />}>Default tile</Tile>);
render(<Tile slug={<AILabel />}>Default tile</Tile>);
expect(
screen.getByRole('button', { name: 'AI - Show information' })
).toBeInTheDocument();
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('Tile', () => {
});

it('should respect slug prop', () => {
render(<ClickableTile slug={<Slug />}>Default tile</ClickableTile>);
render(<ClickableTile slug={<AILabel />}>Default tile</ClickableTile>);

// eslint-disable-next-line testing-library/no-node-access
expect(document.querySelector('svg')).toHaveClass(
Expand Down Expand Up @@ -174,7 +174,11 @@ describe('Tile', () => {

it('should respect slug prop', () => {
render(
<SelectableTile slug={<Slug />} id="tile-1" name="tiles" value="value">
<SelectableTile
slug={<AILabel />}
id="tile-1"
name="tiles"
value="value">
Default tile
</SelectableTile>
);
Expand Down Expand Up @@ -311,7 +315,7 @@ describe('Tile', () => {

it('should respect slug prop', () => {
render(
<ExpandableTile slug={<Slug />}>
<ExpandableTile slug={<AILabel />}>
<TileAboveTheFoldContent>
<div>TestAbove</div>
</TileAboveTheFoldContent>
Expand Down

0 comments on commit 841bda7

Please sign in to comment.