From d14133964860756efde2249a387895502ab1fee7 Mon Sep 17 00:00:00 2001 From: guidari Date: Thu, 10 Oct 2024 16:12:08 -0300 Subject: [PATCH] test: added test to operational tag --- packages/react/src/components/Tag/Tag-test.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/Tag/Tag-test.js b/packages/react/src/components/Tag/Tag-test.js index d6c91848b07d..86fddee5e56e 100644 --- a/packages/react/src/components/Tag/Tag-test.js +++ b/packages/react/src/components/Tag/Tag-test.js @@ -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'; @@ -85,6 +86,37 @@ describe('Tag', () => { }); }); + describe('Operational Tag', () => { + it('should render a operational state', () => { + const { container } = render( + + ); + + 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( + + ); + + await userEvent.click(screen.getByRole('button')); + + expect(onClick).toHaveBeenCalled(); + }); + }); + it('should render with different types', () => { const types = [ 'red',