Skip to content

Commit 7ade379

Browse files
authored
Test/autoComplete (#164)
1 parent 6d4c3af commit 7ade379

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

test/autoComplete.test.tsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { cleanup, render } from '@testing-library/react';
2+
import { ReactMultiEmail } from '../react-multi-email';
3+
import React from 'react';
4+
5+
afterEach(cleanup);
6+
7+
describe('ReactMultiEmail autoComplete prop Test', () => {
8+
it('autoComplete avaliable value', () => {
9+
render(
10+
<ReactMultiEmail
11+
id='inputTarget'
12+
autoComplete='on'
13+
getLabel={(email, index, removeEmail) => {
14+
return (
15+
<div data-tag key={index}>
16+
<div data-tag-item>{email}</div>
17+
<span data-tag-handle onClick={() => removeEmail(index)}>
18+
×
19+
</span>
20+
</div>
21+
);
22+
}}
23+
/>,
24+
);
25+
26+
const inputTarget = document.getElementById('inputTarget');
27+
expect(!!inputTarget?.getAttribute('autoComplete')).toBe(true);
28+
});
29+
30+
it('autoComplete undefined', () => {
31+
render(
32+
<ReactMultiEmail
33+
id='inputTarget'
34+
getLabel={(email, index, removeEmail) => {
35+
return (
36+
<div data-tag key={index}>
37+
<div data-tag-item>{email}</div>
38+
<span data-tag-handle onClick={() => removeEmail(index)}>
39+
×
40+
</span>
41+
</div>
42+
);
43+
}}
44+
/>,
45+
);
46+
47+
const inputTarget = document.getElementById('inputTarget');
48+
expect(!!inputTarget?.getAttribute('autoComplete')).toBe(false);
49+
});
50+
51+
it('autoComplete falsy string', () => {
52+
render(
53+
<ReactMultiEmail
54+
id='inputTarget'
55+
autoComplete=''
56+
getLabel={(email, index, removeEmail) => {
57+
return (
58+
<div data-tag key={index}>
59+
<div data-tag-item>{email}</div>
60+
<span data-tag-handle onClick={() => removeEmail(index)}>
61+
×
62+
</span>
63+
</div>
64+
);
65+
}}
66+
/>,
67+
);
68+
69+
const inputTarget = document.getElementById('inputTarget');
70+
expect(!!inputTarget?.getAttribute('autoComplete')).toBe(false);
71+
});
72+
});

0 commit comments

Comments
 (0)