/
HTMLFormElement.test.ts
62 lines (55 loc) · 1.55 KB
/
HTMLFormElement.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import Window from '../../../src/window/Window';
import Document from '../../../src/nodes/document/Document';
import HTMLFormElement from '../../../src/nodes/html-form-element/HTMLFormElement';
describe('HTMLFormElement', () => {
let window: Window;
let document: Document;
let element: HTMLFormElement;
beforeEach(() => {
window = new Window();
document = window.document;
element = <HTMLFormElement>document.createElement('form');
});
describe('Object.prototype.toString', () => {
it('Returns `[object HTMLFormElement]`', () => {
expect(Object.prototype.toString.call(element)).toBe('[object HTMLFormElement]');
});
});
for (const property of [
'name',
'target',
'action',
'encoding',
'enctype',
'acceptCharset',
'autocomplete',
'noValidate'
]) {
describe(`get ${property}()`, () => {
it('Returns attribute value.', () => {
expect(element[property]).toBe('');
element.setAttribute(property, 'value');
expect(element[property]).toBe('value');
});
});
describe(`set ${property}()`, () => {
it('Sets attribute value.', () => {
element[property] = 'value';
expect(element.getAttribute(property)).toBe('value');
});
});
}
describe('get method()', () => {
it('Returns attribute value.', () => {
expect(element.method).toBe('get');
element.setAttribute('method', 'post');
expect(element.method).toBe('post');
});
});
describe('set method()', () => {
it('Sets attribute value.', () => {
element.method = 'post';
expect(element.getAttribute('method')).toBe('post');
});
});
});