From 0c9434b555fc719c62731525025dcf0dd4eec615 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 24 Jan 2021 18:06:11 +0100 Subject: [PATCH] Created CopyToClipboardIcon test --- test/utils/CopyToClipboardIcon.test.tsx | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/utils/CopyToClipboardIcon.test.tsx diff --git a/test/utils/CopyToClipboardIcon.test.tsx b/test/utils/CopyToClipboardIcon.test.tsx new file mode 100644 index 00000000..9f0d709b --- /dev/null +++ b/test/utils/CopyToClipboardIcon.test.tsx @@ -0,0 +1,27 @@ +import { shallow, ShallowWrapper } from 'enzyme'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faCopy as copyIcon } from '@fortawesome/free-regular-svg-icons'; +import { CopyToClipboardIcon } from '../../src/utils/CopyToClipboardIcon'; + +describe('', () => { + let wrapper: ShallowWrapper; + const onCopy = () => {}; + + beforeEach(() => { + wrapper = shallow(); + }); + afterEach(() => wrapper?.unmount()); + + test('expected components are wrapped', () => { + const copyToClipboard = wrapper.find(CopyToClipboard); + const icon = wrapper.find(FontAwesomeIcon); + + expect(copyToClipboard).toHaveLength(1); + expect(copyToClipboard.prop('text')).toEqual('foo'); + expect(copyToClipboard.prop('onCopy')).toEqual(onCopy); + expect(icon).toHaveLength(1); + expect(icon.prop('icon')).toEqual(copyIcon); + expect(icon.prop('className')).toEqual('ml-2 copy-to-clipboard-icon'); + }); +});