-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathutils.spec.js
More file actions
39 lines (33 loc) · 1.71 KB
/
utils.spec.js
File metadata and controls
39 lines (33 loc) · 1.71 KB
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
import * as Utils from "../../src/utils.js";
describe(`Utils`, () => {
describe(`mediaElementHasSource()`, () => {
it(`Should return true if the element has a src`, () => {
const mockMediaElement = { src: "http://bbc.co.uk" };
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(true);
mockMediaElement.src = "https://google.com";
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(true);
mockMediaElement.src = "fgdfgdfgdg";
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(true);
delete mockMediaElement.src;
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(false);
});
it(`Should return true if the element has a srcObject`, () => {
const mockMediaElement = { srcObject: {} };
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(true);
});
it(`Should return false if the src is an empty string or undefined`, () => {
const mockMediaElement = { src: "" };
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(false);
mockMediaElement.src = undefined;
expect(Utils.mediaElementHasSource(mockMediaElement)).toBe(false);
});
it(`Should return false if the src and srcObject do not exist`, () => {
expect(Utils.mediaElementHasSource({})).toBe(false);
});
it(`Should throw given empty argument`, () => {
expect(() => Utils.mediaElementHasSource()).toThrow();
expect(() => Utils.mediaElementHasSource(null)).toThrow();
expect(() => Utils.mediaElementHasSource(undefined)).toThrow();
});
});
});