From a353fd079af03aa3aa61d98853bc568741a55d3c Mon Sep 17 00:00:00 2001 From: Daewon Kim <52730665+vinyl810@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:11:39 +0900 Subject: [PATCH] test className prop (#160) * test: className * test: add test case with no prop --- test/className.test.tsx | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/className.test.tsx diff --git a/test/className.test.tsx b/test/className.test.tsx new file mode 100644 index 0000000..f92d35f --- /dev/null +++ b/test/className.test.tsx @@ -0,0 +1,46 @@ +import { cleanup, render } from '@testing-library/react'; +import { ReactMultiEmail } from '../react-multi-email'; +import React from 'react'; + +afterEach(cleanup); + +describe('ReactMultEmail className TEST', () => { + it('className is correctly assigned', async () => { + render( + { + return ( +
+
{email}
+ removeEmail(index)}> + × + +
+ ); + }} + />, + ); + const el: HTMLElement | null = document.querySelector('div.react-multi-email'); + expect(el?.className.includes('ef3a7c')).toBe(true); + }); + it('className is in default when prop is not provided.', async () => { + render( + { + return ( +
+
{email}
+ removeEmail(index)}> + × + +
+ ); + }} + />, + ); + const el: HTMLElement | null = document.querySelector('div.react-multi-email'); + const regex = new RegExp(`^( )*(react-multi-email( )*empty|focused){1}( )*$`); + expect(regex.test(el?.className ?? '')).toBe(true); + }); +});