forked from capricorn86/happy-dom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTMLMediaElement.test.ts
44 lines (38 loc) · 1.18 KB
/
HTMLMediaElement.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
import Window from '../../../src/window/Window';
import IWindow from '../../../src/window/IWindow';
import IDocument from '../../../src/nodes/document/IDocument';
import IHTMLMediaElement from '../../../src/nodes/html-media-element/IHTMLMediaElement';
describe('HTMLMediaElement', () => {
let window: IWindow;
let document: IDocument;
let element: IHTMLMediaElement;
beforeEach(() => {
window = new Window();
document = window.document;
element = <IHTMLMediaElement>document.createElement('audio');
});
afterEach(() => {
jest.restoreAllMocks();
});
for (const property of ['autoplay', 'controls', 'paused', 'loop', 'muted']) {
describe(`get ${property}()`, () => {
it('Returns attribute value.', () => {
expect(element[property]).toBe(false);
element.setAttribute(property, '');
expect(element[property]).toBe(true);
});
});
describe(`set ${property}()`, () => {
it('Sets attribute value.', () => {
element[property] = true;
expect(element.getAttribute(property)).toBe('');
});
});
}
describe('paused', () => {
it('Set paused attribute as well', () => {
element.pause();
expect(element.getAttribute('paused')).toBe('');
});
});
});