Skip to content

Commit

Permalink
test className prop (#160)
Browse files Browse the repository at this point in the history
* test: className

* test: add test case with no prop
  • Loading branch information
vinyl810 authored Sep 21, 2023
1 parent d98917c commit a353fd0
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/className.test.tsx
Original file line number Diff line number Diff line change
@@ -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(
<ReactMultiEmail
className='ef3a7c'
getLabel={(email, index, removeEmail) => {
return (
<div data-tag key={index}>
<div data-tag-item>{email}</div>
<span data-tag-handle onClick={() => removeEmail(index)}>
×
</span>
</div>
);
}}
/>,
);
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(
<ReactMultiEmail
getLabel={(email, index, removeEmail) => {
return (
<div data-tag key={index}>
<div data-tag-item>{email}</div>
<span data-tag-handle onClick={() => removeEmail(index)}>
×
</span>
</div>
);
}}
/>,
);
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);
});
});

1 comment on commit a353fd0

@vercel
Copy link

@vercel vercel bot commented on a353fd0 Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-multi-email – ./

react-multi-email.vercel.app
react-multi-email-axframe.vercel.app
react-multi-email-git-master-axframe.vercel.app

Please sign in to comment.