Skip to content

Commit

Permalink
test: added test to operational tag (#17717)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidari authored Oct 11, 2024
1 parent 4b4fe02 commit 0015363
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion packages/react/src/components/Tag/Tag-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import { Add } from '@carbon/icons-react';
import { render, screen } from '@testing-library/react';
import React from 'react';
import Tag, { TagSkeleton } from './';
import Tag, { OperationalTag, TagSkeleton } from './';
import DismissibleTag from './DismissibleTag';
import { AILabel } from '../AILabel';
import { Asleep } from '@carbon/icons-react';
import userEvent from '@testing-library/user-event';

const prefix = 'cds';

Expand Down Expand Up @@ -85,6 +86,37 @@ describe('Tag', () => {
});
});

describe('Operational Tag', () => {
it('should render a operational state', () => {
const { container } = render(
<OperationalTag type="red" className="some-class" text="Tag content" />
);

const operationalTag = container.querySelector(
`.${prefix}--tag--operational `
);

expect(operationalTag).toHaveClass(`${prefix}--tag--operational `);
});

it('should accept other props such as onClick', async () => {
const onClick = jest.fn();

const { container } = render(
<OperationalTag
type="red"
className="some-class"
text="Tag content"
onClick={onClick}
/>
);

await userEvent.click(screen.getByRole('button'));

expect(onClick).toHaveBeenCalled();
});
});

it('should render with different types', () => {
const types = [
'red',
Expand Down

0 comments on commit 0015363

Please sign in to comment.