1 | import VideoSource from './video_source';
|
2 | import {extend} from '../util/util';
|
3 | import {getMockDispatcher} from '../util/test/util';
|
4 |
|
5 | import type {Coordinates} from './image_source';
|
6 |
|
7 | function createSource(options) {
|
8 | const c = options && options.video || window.document.createElement('video');
|
9 |
|
10 | options = extend({coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]]}, options);
|
11 |
|
12 | const source = new VideoSource('id', options, getMockDispatcher(), options.eventedParent);
|
13 |
|
14 | source.video = c;
|
15 | return source;
|
16 | }
|
17 |
|
18 | describe('VideoSource', () => {
|
19 |
|
20 | const source = createSource({
|
21 | type: 'video',
|
22 | urls : [ 'cropped.mp4', 'https://upload.wikimedia.org/wikipedia/commons/2/22/Volcano_Lava_Sample.webm' ],
|
23 | coordinates: [
|
24 | [-76.54, 39.18],
|
25 | [-76.52, 39.18],
|
26 | [-76.52, 39.17],
|
27 | [-76.54, 39.17]
|
28 | ]
|
29 | });
|
30 |
|
31 | test('constructor', () => {
|
32 | expect(source.minzoom).toBe(0);
|
33 | expect(source.maxzoom).toBe(22);
|
34 | expect(source.tileSize).toBe(512);
|
35 | });
|
36 |
|
37 | test('sets coordinates', () => {
|
38 | const newCoordinates = [[0, 0], [-1, 0], [-1, -1], [0, -1]] as Coordinates;
|
39 | source.setCoordinates(newCoordinates);
|
40 | const serialized = source.serialize();
|
41 |
|
42 | expect(serialized.coordinates).toEqual(newCoordinates);
|
43 |
|
44 | });
|
45 |
|
46 |
|
47 | test('gets video', () => {
|
48 | const el = window.document.createElement('video');
|
49 |
|
50 | const source = createSource({
|
51 | type: 'video',
|
52 | video: el,
|
53 | urls : [ 'cropped.mp4', 'https://upload.wikimedia.org/wikipedia/commons/2/22/Volcano_Lava_Sample.webm' ],
|
54 | coordinates: [
|
55 | [-76.54, 39.18],
|
56 | [-76.52, 39.18],
|
57 | [-76.52, 39.17],
|
58 | [-76.54, 39.17]
|
59 | ]
|
60 | });
|
61 |
|
62 | expect(source.getVideo()).toBe(el);
|
63 | });
|
64 | });
|