Skip to content

Commit 7a6bf5e

Browse files
Eran MachielsEranNL
andauthored
Feature/validate all elements (#9)
* WIP validation all elements * Fixes * Added missing docs * Added some dom tests * Fixes Co-authored-by: Eran Machiels <dev@eranmachiels.nl>
1 parent d20625c commit 7a6bf5e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

__tests__/utils/dom.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getValue, htmlCollectionToArray } from '@/utils/dom';
1+
import { getValue, htmlCollectionToArray, isInputElement, isSelectElement } from '@/utils/dom';
22

33
describe('dom helpers test', () => {
44
it('should convert HtmlCollection to array', () => {
@@ -32,6 +32,19 @@ describe('dom helpers test', () => {
3232
expect(getValue(select)).toEqual(expect.arrayContaining(['foo', 'bar']));
3333
expect(getValue(input)).toBe('baz');
3434
expect(getValue(div)).toBeNull();
35+
});
3536

36-
})
37+
it('should check whether an element is an input element', () => {
38+
const input = document.createElement('input');
39+
const textarea = document.createElement('textarea');
40+
41+
expect(isInputElement(input)).toBeTruthy();
42+
expect(isInputElement(textarea)).toBeTruthy();
43+
});
44+
45+
it('should check whether an element is an input element', () => {
46+
const select = document.createElement('select');
47+
48+
expect(isSelectElement(select)).toBeTruthy();
49+
});
3750
});

0 commit comments

Comments
 (0)