diff --git a/packages/react/src/components/UnorderedList/UnorderedList-test.js b/packages/react/src/components/UnorderedList/UnorderedList-test.js index 34f6420cff27..6d6a981e80ec 100644 --- a/packages/react/src/components/UnorderedList/UnorderedList-test.js +++ b/packages/react/src/components/UnorderedList/UnorderedList-test.js @@ -8,36 +8,43 @@ import React from 'react'; import UnorderedList from '../UnorderedList'; import ListItem from '../ListItem'; -import { shallow } from 'enzyme'; import { settings } from 'carbon-components'; +import { render, screen } from '@testing-library/react'; const { prefix } = settings; + describe('UnorderedList', () => { - describe('Renders as expected', () => { - const list = shallow( - + it('should render children as expected', () => { + render( + Item ); + expect(screen.getByText('Item')).toBeInTheDocument(); + }); - it('should be a ul element', () => { - expect(list.find('ul').length).toEqual(1); - }); + it('should render nested lists', () => { + render( + + Item + + Nested + + + ); - it('should render with the appropriate classes', () => { - expect(list.hasClass(`${prefix}--list--unordered`)).toEqual(true); - expect(list.hasClass('some-class')).toEqual(true); - }); + expect(screen.getByTestId('nested-list')).toHaveClass( + `${prefix}--list--nested` + ); + }); - it('should render children as expected', () => { - expect(list.find(ListItem).length).toEqual(1); - }); + it('should add custom className given via className prop', () => { + render( + + Item + + ); - it('should render nested lists', () => { - list.setProps({ nested: true }); - expect(list.hasClass(`${prefix}--list--nested`)).toEqual(true); - list.setProps({ nested: false }); - expect(list.hasClass(`${prefix}--list--nested`)).toEqual(false); - }); + expect(screen.getByTestId('list')).toHaveClass('some-class'); }); });