From 1d51f749b74952bcc4e1d69b04f66c20adac80af Mon Sep 17 00:00:00 2001 From: Raul Date: Wed, 27 Jan 2016 00:32:31 +0100 Subject: [PATCH] fix(testing): Improved coverage Small fixes and improved coverage to 100% for player and api. --- src/services/vg-api.spec.ts | 535 +++++++++++++++++++++++++ src/services/vg-api.ts | 18 +- src/services/vg-fullscreen-api.spec.ts | 60 +++ src/services/vg-fullscreen-api.ts | 77 ++-- src/vg-player/vg-player.spec.ts | 5 +- videogular2.d.ts | 28 +- videogular2.js | 26 +- 7 files changed, 671 insertions(+), 78 deletions(-) create mode 100644 src/services/vg-api.spec.ts create mode 100644 src/services/vg-fullscreen-api.spec.ts diff --git a/src/services/vg-api.spec.ts b/src/services/vg-api.spec.ts new file mode 100644 index 00000000..161c9792 --- /dev/null +++ b/src/services/vg-api.spec.ts @@ -0,0 +1,535 @@ +import {it, describe, expect, beforeEach, inject} from 'angular2/testing'; +import {VgAPI} from "../services/vg-api"; +import {VgFullscreenAPI} from "../services/vg-fullscreen-api"; +import {VgEvents} from "../events/vg-events"; + + +describe('Videogular Player', () => { + let api:VgAPI; + + beforeEach(() => { + api = new VgAPI(); + }); + + it('Should initialize fullscreen api when api is created', () => { + spyOn(VgFullscreenAPI, 'init').and.callFake(() => {}); + api = new VgAPI(); + expect(VgFullscreenAPI.init).toHaveBeenCalled(); + }); + + it('Should get the default media', () => { + api.medias = { + main: {id: 'main'}, + secondary: {id: 'secondary'} + }; + + expect(api.getDefaultMedia()).toEqual({id: 'main'}); + }); + + it('Should get the api if we do not pass an id', () => { + api.medias = { + main: {id: 'main'}, + secondary: {id: 'secondary'} + }; + + expect(api.getMediaById()).toEqual(api); + }); + + it('Should get the api if we pass an *', () => { + api.medias = { + main: {id: 'main'}, + secondary: {id: 'secondary'} + }; + + expect(api.getMediaById('*')).toEqual(api); + }); + + it('Should get a media object if we pass an id', () => { + api.medias = { + main: {id: 'main'}, + secondary: {id: 'secondary'} + }; + + expect(api.getMediaById('main')).toEqual({id: 'main'}); + }); + + it('Should play all medias', () => { + api.medias = { + main: {id: 'main', play: () => {}}, + secondary: {id: 'secondary', play: () => {}} + }; + + spyOn((api.medias).main, 'play').and.callThrough(); + spyOn((api.medias).secondary, 'play').and.callThrough(); + + api.play(); + + expect((api.medias).main.play).toHaveBeenCalled(); + expect((api.medias).secondary.play).toHaveBeenCalled(); + }); + + it('Should pause all medias', () => { + api.medias = { + main: {id: 'main', pause: () => {}}, + secondary: {id: 'secondary', pause: () => {}} + }; + + spyOn((api.medias).main, 'pause').and.callThrough(); + spyOn((api.medias).secondary, 'pause').and.callThrough(); + + api.pause(); + + expect((api.medias).main.pause).toHaveBeenCalled(); + expect((api.medias).secondary.pause).toHaveBeenCalled(); + }); + + it('Should get duration', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var duration = api.duration; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('duration'); + }); + + it('Should set a state', () => { + spyOn(api, '$$setAllProperties').and.callFake(() => {}); + + api.state = 'pause'; + + expect(api.$$setAllProperties).toHaveBeenCalledWith('state', 'pause'); + }); + + it('Should get state', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var state = api.state; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('state'); + }); + + it('Should set a volume', () => { + spyOn(api, '$$setAllProperties').and.callFake(() => {}); + + api.volume = 0.5; + + expect(api.$$setAllProperties).toHaveBeenCalledWith('volume', 0.5); + }); + + it('Should get volume', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var volume = api.volume; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('volume'); + }); + + it('Should set a playback rate', () => { + spyOn(api, '$$setAllProperties').and.callFake(() => {}); + + api.playbackRate = 0.5; + + expect(api.$$setAllProperties).toHaveBeenCalledWith('playbackRate', 0.5); + }); + + it('Should get playbackRate', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var playbackRate = api.playbackRate; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('playbackRate'); + }); + + it('Should get canPlay', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var canPlay = api.canPlay; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('canPlay'); + }); + + it('Should get canPlayThrough', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var canPlayThrough = api.canPlayThrough; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('canPlayThrough'); + }); + + it('Should get isMetadataLoaded', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var isMetadataLoaded = api.isMetadataLoaded; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('isMetadataLoaded'); + }); + + it('Should get isWaiting', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var isWaiting = api.isWaiting; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('isWaiting'); + }); + + it('Should get isCompleted', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var isCompleted = api.isCompleted; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('isCompleted'); + }); + + it('Should get time', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var time = api.time; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('time'); + }); + + it('Should get buffered', () => { + spyOn(api, '$$getAllProperties').and.callFake(() => {}); + + var buffered = api.buffered; + + expect(api.$$getAllProperties).toHaveBeenCalledWith('buffered'); + }); + + it('Should seek to a specified time by second', () => { + api.medias = { + main: {id: 'main'}, + secondary: {id: 'secondary'} + }; + + spyOn(api, '$$seek').and.callFake(() => {}); + + api.seekTime(10); + + expect(api.$$seek).toHaveBeenCalledWith({id: 'main'}, 10, false); + expect(api.$$seek).toHaveBeenCalledWith({id: 'secondary'}, 10, false); + }); + + it('Should seek to a specified time by percentage', () => { + api.medias = { + main: {id: 'main'}, + secondary: {id: 'secondary'} + }; + + spyOn(api, '$$seek').and.callFake(() => {}); + + api.seekTime(10, true); + + expect(api.$$seek).toHaveBeenCalledWith({id: 'main'}, 10, true); + expect(api.$$seek).toHaveBeenCalledWith({id: 'secondary'}, 10, true); + }); + + it('Should seek media files to a specified time by second', () => { + var media = { + currentTime: 0 + }; + + api.$$seek(media, 10); + + expect(media.currentTime).toBe(10); + }); + + it('Should seek media files to a specified time by percentage', () => { + var media = { + duration: 200, + currentTime: 0 + }; + + api.$$seek(media, 10, true); + + expect(media.currentTime).toBe(20); + }); + + it('Should get a property from all media objects and return an object', () => { + api.medias = { + main: {id: 'main', state: 'play'}, + secondary: {id: 'secondary', state: 'pause'} + }; + + var states = api.$$getAllProperties('state'); + + expect(states).toEqual({ + main: 'play', + secondary: 'pause' + }); + }); + + it('Should get a property from all media objects and return a plain value if there is only one media object', () => { + api.medias = { + main: {id: 'main', state: 'play'} + }; + + var states = api.$$getAllProperties('state'); + + expect(states).toEqual('play'); + }); + + it('Should set a property to all media objects', () => { + api.medias = { + main: {id: 'main', state: 'stop'}, + secondary: {id: 'secondary', state: 'stop'} + }; + + api.$$setAllProperties('state', 'play'); + + expect((api.medias).main.state).toBe('play'); + expect((api.medias).secondary.state).toBe('play'); + }); + + it('Should register a new media object', () => { + var media = {id: 'main'}; + + spyOn(api, 'connect').and.callFake(() => {}); + + api.registerMedia(media); + + expect((media).time.current).toBe(0); + expect((media).time.total).toBe(0); + expect((media).time.left).toBe(0); + expect((media).buffer.end).toBe(0); + expect((media).canPlay).toBeFalsy(); + expect((media).canPlayThrough).toBeFalsy(); + expect((media).isMetadataLoaded).toBeFalsy(); + expect((media).isWaiting).toBeFalsy(); + expect((media).isCompleted).toBeFalsy(); + expect((media).state).toBe('pause'); + + expect((api.medias).main).toBe(media); + + expect(api.connect).toHaveBeenCalledWith(media); + + spyOn(api, '$$seek').and.callFake(() => {}); + + (media).seekTime(10); + (media).seekTime(20, true); + + expect(api.$$seek).toHaveBeenCalledWith(media, 10, false); + expect(api.$$seek).toHaveBeenCalledWith(media, 20, true); + }); + + it('Should enter videogular element to fullscreen mode', () => { + api.videogularElement = {id: 'vgElem'}; + + spyOn(VgFullscreenAPI, 'isFullscreen').and.callFake(() => {return false;}); + spyOn(VgFullscreenAPI, 'request').and.callFake(() => {}); + + api.toggleFullscreen(); + + expect(VgFullscreenAPI.isFullscreen).toHaveBeenCalled(); + expect(VgFullscreenAPI.request).toHaveBeenCalledWith(api.videogularElement); + }); + + it('Should enter other element to fullscreen mode', () => { + var element = {id: 'main'}; + + api.videogularElement = {id: 'vgElem'}; + + spyOn(VgFullscreenAPI, 'isFullscreen').and.callFake(() => {return false;}); + spyOn(VgFullscreenAPI, 'request').and.callFake(() => {}); + + api.toggleFullscreen(element); + + expect(VgFullscreenAPI.isFullscreen).toHaveBeenCalled(); + expect(VgFullscreenAPI.request).toHaveBeenCalledWith(element); + }); + + it('Should exit from fullscreen mode', () => { + spyOn(VgFullscreenAPI, 'isFullscreen').and.callFake(() => {return true;}); + spyOn(VgFullscreenAPI, 'exit').and.callFake(() => {}); + + api.toggleFullscreen(); + + expect(VgFullscreenAPI.isFullscreen).toHaveBeenCalled(); + expect(VgFullscreenAPI.exit).toHaveBeenCalled(); + }); + + it('Should return if player is in fullscreen mode', () => { + spyOn(VgFullscreenAPI, 'isFullscreen').and.callFake(() => {}); + + api.isFullscreen(); + + expect(VgFullscreenAPI.isFullscreen).toHaveBeenCalled(); + }); + + it('Should add event listeners to media', () => { + var media = { + id: 'main', + addEventListener: () => {} + }; + + spyOn(media, 'addEventListener').and.callFake(() => {}); + + api.connect(media); + + expect(media.addEventListener).toHaveBeenCalled(); + }); + + it('Should handle onCanPlay event', () => { + api.medias = { + main: {id: 'main', canPlay: false}, + secondary: {id: 'secondary', canPlay: false} + }; + + api.onCanPlay('main'); + + expect((api.medias).main.canPlay).toBeTruthy(); + }); + + it('Should handle onCanPlayThrough event', () => { + api.medias = { + main: {id: 'main', canPlayThrough: false}, + secondary: {id: 'secondary', canPlayThrough: false} + }; + + api.onCanPlayThrough('main'); + + expect((api.medias).main.canPlayThrough).toBeTruthy(); + }); + + it('Should handle onLoadMetadata event', () => { + api.medias = { + main: {id: 'main', isMetadataLoaded: false, duration: 97.317, time: {total: 0}}, + secondary: {id: 'secondary', isMetadataLoaded: false, duration: 297.317, time: {total: 0}} + }; + + api.onLoadMetadata('main'); + + expect((api.medias).main.isMetadataLoaded).toBeTruthy(); + expect((api.medias).main.time.total).toBe(97317); + }); + + it('Should handle onWait event', () => { + api.medias = { + main: {id: 'main', isWaiting: false}, + secondary: {id: 'secondary', isWaiting: false} + }; + + api.onWait('main'); + + expect((api.medias).main.isWaiting).toBeTruthy(); + }); + + it('Should handle onComplete event', () => { + api.medias = { + main: {id: 'main', isCompleted: false, state: 'play'}, + secondary: {id: 'secondary', isCompleted: false, state: 'play'} + }; + + api.onComplete('main'); + + expect((api.medias).main.isCompleted).toBeTruthy(); + expect((api.medias).main.state).toBe('pause'); + }); + + it('Should handle onStartPlaying event', () => { + api.medias = { + main: {id: 'main', state: 'pause'}, + secondary: {id: 'secondary', state: 'pause'} + }; + + api.onStartPlaying('main'); + + expect((api.medias).main.state).toBe('play'); + }); + + it('Should handle onPlay event', () => { + api.medias = { + main: {id: 'main', state: 'pause'}, + secondary: {id: 'secondary', state: 'pause'} + }; + + api.onPlay('main'); + + expect((api.medias).main.state).toBe('play'); + }); + + it('Should handle onPause event', () => { + api.medias = { + main: {id: 'main', state: 'play'}, + secondary: {id: 'secondary', state: 'play'} + }; + + api.onPause('main'); + + expect((api.medias).main.state).toBe('pause'); + }); + + it('Should handle onPlaybackChange event', () => { + api.medias = { + main: {id: 'main', playbackRate: 1}, + secondary: {id: 'secondary', playbackRate: 1} + }; + + api.onPlaybackChange('main', 2); + + expect((api.medias).main.playbackRate).toBe(2); + }); + + it('Should handle onTimeUpdate event', () => { + api.medias = { + main: { + id: 'main', + currentTime: 12.345, + duration: 97.317, + buffered: { + length: 2, + end: () => { + return 40; + } + }, + time: { + current: 0, + left: 0 + }, + buffer: { + end: 0 + } + } + }; + + spyOn((api.medias).main.buffered, 'end').and.callThrough(); + + api.onTimeUpdate('main'); + + expect((api.medias).main.buffered.end).toHaveBeenCalledWith(1); + expect((api.medias).main.time.current).toBe(12345); + expect((api.medias).main.time.left).toBe(84972); + expect((api.medias).main.buffer.end).toBe(40000); + }); + + it('Should handle onProgress event', () => { + api.medias = { + main: { + id: 'main', + buffered: { + length: 2, + end: () => { + return 40; + } + }, + buffer: { + end: 0 + } + } + }; + + spyOn((api.medias).main.buffered, 'end').and.callThrough(); + + api.onProgress('main'); + + expect((api.medias).main.buffered.end).toHaveBeenCalledWith(1); + expect((api.medias).main.buffer.end).toBe(40000); + }); + + it('Should handle onVolumeChange event', () => { + api.onVolumeChange('main'); + }); + + it('Should handle onError event', () => { + api.onError('main'); + }); +}); diff --git a/src/services/vg-api.ts b/src/services/vg-api.ts index 0699a67f..d114823e 100644 --- a/src/services/vg-api.ts +++ b/src/services/vg-api.ts @@ -17,7 +17,7 @@ export class VgAPI { } } - getMediaById(id:string) { + getMediaById(id:string = null) { var media = this.medias[id]; if (!id || id === '*') { @@ -95,13 +95,13 @@ export class VgAPI { return this.$$getAllProperties('buffered'); } - seekTime(value:number = 0, byPercent:boolean = false) { + seekTime(value:number, byPercent:boolean = false) { for (var id in this.medias) { this.$$seek(this.medias[id], value, byPercent); } } - $$seek(media:HTMLVideoElement|HTMLAudioElement, value:number = 0, byPercent:boolean = false) { + $$seek(media:HTMLVideoElement|HTMLAudioElement, value:number, byPercent:boolean = false) { var second; if (byPercent) { @@ -155,7 +155,7 @@ export class VgAPI { media.isWaiting = false; media.isCompleted = false; media.state = 'pause'; - media.seekTime = (value:number=0, byPercent:boolean=false) => { + media.seekTime = (value:number, byPercent:boolean = false) => { this.$$seek(media, value, byPercent); }; @@ -165,7 +165,7 @@ export class VgAPI { } // TODO: Add support for mobile devices - toggleFullscreen(element) { + toggleFullscreen(element:any = null) { if (!element) element = this.videogularElement; if (VgFullscreenAPI.isFullscreen()) { @@ -180,7 +180,7 @@ export class VgAPI { return VgFullscreenAPI.isFullscreen(); } - connect(media:HTMLElement) { + connect(media:any) { media.addEventListener(VgEvents.VG_CAN_PLAY, this.onCanPlay.bind(this, media.id), false); media.addEventListener(VgEvents.VG_CAN_PLAY_THROUGH, this.onCanPlayThrough.bind(this, media.id), false); media.addEventListener(VgEvents.VG_LOADED_METADATA, this.onLoadMetadata.bind(this, media.id), false); @@ -231,7 +231,7 @@ export class VgAPI { this.medias[id].state = 'pause'; } - onPlaybackChange(id: string, rate: string) { + onPlaybackChange(id: string, rate: number) { this.medias[id].playbackRate = rate; } @@ -246,10 +246,10 @@ export class VgAPI { } onVolumeChange(id:string) { - //this.medias[id].volume = this.medias[id].volume; + // TODO: Save to localstorage the current volume } onError(id:string) { - console.log('error'); + // TODO: Handle error messages } } diff --git a/src/services/vg-fullscreen-api.spec.ts b/src/services/vg-fullscreen-api.spec.ts new file mode 100644 index 00000000..01e13f39 --- /dev/null +++ b/src/services/vg-fullscreen-api.spec.ts @@ -0,0 +1,60 @@ +import {it, describe, expect, beforeEach, inject} from 'angular2/testing'; +import {VgFullscreenAPI} from "../services/vg-fullscreen-api"; + + +describe('Videogular Player', () => { + beforeEach(() => { + VgFullscreenAPI.init(); + }); + + it('Should create polyfills on init', () => { + expect(VgFullscreenAPI.polyfill.enabled).toBe('webkitFullscreenEnabled'); + expect(VgFullscreenAPI.polyfill.element).toBe('webkitFullscreenElement'); + expect(VgFullscreenAPI.polyfill.request).toBe('webkitRequestFullscreen'); + expect(VgFullscreenAPI.polyfill.exit).toBe('webkitExitFullscreen'); + expect(VgFullscreenAPI.polyfill.onchange).toBe('webkitfullscreenchange'); + expect(VgFullscreenAPI.polyfill.onerror).toBe('webkitfullscreenerror'); + }); + + it('Should return if an element is in fullscreen mode', () => { + let isFullscreen; + + VgFullscreenAPI.polyfill.element = 'mockedElementFunction'; + + (document).mockedElementFunction = {}; + + isFullscreen = VgFullscreenAPI.isFullscreen(); + + expect(isFullscreen).toBeTruthy(); + + (document).mockedElementFunction = undefined; + + isFullscreen = VgFullscreenAPI.isFullscreen(); + + expect(isFullscreen).toBeFalsy(); + }); + + it('Should request an element to enter in fullscreen mode', () => { + let elem = { + webkitRequestFullscreen: () => {} + }; + + spyOn(elem, 'webkitRequestFullscreen').and.callThrough(); + + VgFullscreenAPI.request(elem); + + expect(elem.webkitRequestFullscreen).toHaveBeenCalled(); + }); + + it('Should request an element to exit from fullscreen mode', () => { + VgFullscreenAPI.polyfill.exit = 'mockedExitFunction'; + + (document).mockedExitFunction = () => {}; + + spyOn(document, 'mockedExitFunction').and.callThrough(); + + VgFullscreenAPI.exit(); + + expect((document).mockedExitFunction).toHaveBeenCalled(); + }); +}); diff --git a/src/services/vg-fullscreen-api.ts b/src/services/vg-fullscreen-api.ts index 5eff159c..f7e484fa 100644 --- a/src/services/vg-fullscreen-api.ts +++ b/src/services/vg-fullscreen-api.ts @@ -9,52 +9,52 @@ export class VgFullscreenAPI { static init() { const APIs = { w3: { - enabled: "fullscreenEnabled", - element: "fullscreenElement", - request: "requestFullscreen", - exit: "exitFullscreen", - onchange: "fullscreenchange", - onerror: "fullscreenerror" + enabled: 'fullscreenEnabled', + element: 'fullscreenElement', + request: 'requestFullscreen', + exit: 'exitFullscreen', + onchange: 'fullscreenchange', + onerror: 'fullscreenerror' }, newWebkit: { - enabled: "webkitFullscreenEnabled", - element: "webkitFullscreenElement", - request: "webkitRequestFullscreen", - exit: "webkitExitFullscreen", - onchange: "webkitfullscreenchange", - onerror: "webkitfullscreenerror" + enabled: 'webkitFullscreenEnabled', + element: 'webkitFullscreenElement', + request: 'webkitRequestFullscreen', + exit: 'webkitExitFullscreen', + onchange: 'webkitfullscreenchange', + onerror: 'webkitfullscreenerror' }, oldWebkit: { - enabled: "webkitIsFullScreen", - element: "webkitCurrentFullScreenElement", - request: "webkitRequestFullScreen", - exit: "webkitCancelFullScreen", - onchange: "webkitfullscreenchange", - onerror: "webkitfullscreenerror" + enabled: 'webkitIsFullScreen', + element: 'webkitCurrentFullScreenElement', + request: 'webkitRequestFullScreen', + exit: 'webkitCancelFullScreen', + onchange: 'webkitfullscreenchange', + onerror: 'webkitfullscreenerror' }, moz: { - enabled: "mozFullScreen", - element: "mozFullScreenElement", - request: "mozRequestFullScreen", - exit: "mozCancelFullScreen", - onchange: "mozfullscreenchange", - onerror: "mozfullscreenerror" + enabled: 'mozFullScreen', + element: 'mozFullScreenElement', + request: 'mozRequestFullScreen', + exit: 'mozCancelFullScreen', + onchange: 'mozfullscreenchange', + onerror: 'mozfullscreenerror' }, ios: { - enabled: "webkitFullscreenEnabled", - element: "webkitFullscreenElement", - request: "webkitEnterFullscreen", - exit: "webkitExitFullscreen", - onchange: "webkitfullscreenchange", - onerror: "webkitfullscreenerror" + enabled: 'webkitFullscreenEnabled', + element: 'webkitFullscreenElement', + request: 'webkitEnterFullscreen', + exit: 'webkitExitFullscreen', + onchange: 'webkitfullscreenchange', + onerror: 'webkitfullscreenerror' }, ms: { - enabled: "msFullscreenEnabled", - element: "msFullscreenElement", - request: "msRequestFullscreen", - exit: "msExitFullscreen", - onchange: "MSFullscreenChange", - onerror: "MSFullscreenError" + enabled: 'msFullscreenEnabled', + element: 'msFullscreenElement', + request: 'msRequestFullscreen', + exit: 'msExitFullscreen', + onchange: 'MSFullscreenChange', + onerror: 'MSFullscreenError' } }; @@ -64,11 +64,6 @@ export class VgFullscreenAPI { break; } } - - if (this.polyfill) { - this.onchange = this.polyfill.onchange; - this.onerror = this.polyfill.onerror; - } } static isFullscreen() { diff --git a/src/vg-player/vg-player.spec.ts b/src/vg-player/vg-player.spec.ts index 31859a6d..45dcd201 100644 --- a/src/vg-player/vg-player.spec.ts +++ b/src/vg-player/vg-player.spec.ts @@ -6,7 +6,7 @@ import {ElementRef} from "angular2/core"; describe('Videogular Player', () => { let player:VgPlayer; let ref:ElementRef; - let api:VgAPI = new VgAPI(); + let api:VgAPI; beforeEach(() => { ref = { @@ -17,16 +17,19 @@ describe('Videogular Player', () => { } }; + api = new VgAPI(); player = new VgPlayer(ref, api); }); it('Should get all medias on init', () => { spyOn(player.elem, 'querySelectorAll').and.callThrough(); spyOn(api, 'registerMedia').and.callFake(() => {}); + spyOn(player.onPlayerReady, 'next').and.callFake(() => {}); player.ngOnInit(); expect(player.elem.querySelectorAll).toHaveBeenCalledWith('video'); expect(api.registerMedia).toHaveBeenCalledWith({}); + expect(player.onPlayerReady.next).toHaveBeenCalledWith(player.API); }); }); diff --git a/videogular2.d.ts b/videogular2.d.ts index 36f1329d..4ca7683f 100644 --- a/videogular2.d.ts +++ b/videogular2.d.ts @@ -1,18 +1,18 @@ -export * from './lib/vg-player/vg-player'; +export * from './dist/vg-player/vg-player'; -export * from './lib/vg-overlay-play/vg-overlay-play'; -export * from './lib/vg-controls/vg-controls'; -export * from './lib/vg-controls/vg-fullscreen/vg-fullscreen'; -export * from './lib/vg-controls/vg-mute/vg-mute'; -export * from './lib/vg-controls/vg-play-pause/vg-play-pause'; -export * from './lib/vg-controls/vg-playback-button/vg-playback-button'; -export * from './lib/vg-controls/vg-scrub-bar/vg-scrub-bar'; -export * from './lib/vg-controls/vg-scrub-bar/vg-scrub-bar-buffering-time/vg-scrub-bar-buffering-time'; -export * from './lib/vg-controls/vg-scrub-bar/vg-scrub-bar-current-time/vg-scrub-bar-current-time'; +export * from './dist/vg-overlay-play/vg-overlay-play'; +export * from './dist/vg-controls/vg-controls'; +export * from './dist/vg-controls/vg-fullscreen/vg-fullscreen'; +export * from './dist/vg-controls/vg-mute/vg-mute'; +export * from './dist/vg-controls/vg-play-pause/vg-play-pause'; +export * from './dist/vg-controls/vg-playback-button/vg-playback-button'; +export * from './dist/vg-controls/vg-scrub-bar/vg-scrub-bar'; +export * from './dist/vg-controls/vg-scrub-bar/vg-scrub-bar-buffering-time/vg-scrub-bar-buffering-time'; +export * from './dist/vg-controls/vg-scrub-bar/vg-scrub-bar-current-time/vg-scrub-bar-current-time'; -export * from './lib/vg-overlay-play/vg-overlay-play'; +export * from './dist/vg-overlay-play/vg-overlay-play'; -export * from './lib/events/vg-events'; +export * from './dist/events/vg-events'; -export * from './lib/services/vg-api'; -export * from './lib/services/vg-fullscreen-api'; +export * from './dist/services/vg-api'; +export * from './dist/services/vg-fullscreen-api'; diff --git a/videogular2.js b/videogular2.js index 31f30ea0..4be12c8b 100644 --- a/videogular2.js +++ b/videogular2.js @@ -1,17 +1,17 @@ -exports.VgPlayer = require('./lib/vg-player/vg-player').VgPlayer; +exports.VgPlayer = require('./dist/vg-player/vg-player').VgPlayer; -exports.VgControls = require('./lib/vg-controls/vg-controls').VgControls; -exports.VgFullscreen = require('./lib/vg-controls/vg-fullscreen/vg-fullscreen').VgFullscreen; -exports.VgMute = require('./lib/vg-controls/vg-mute/vg-mute').VgMute; -exports.VgPlayPause = require('./lib/vg-controls/vg-play-pause/vg-play-pause').VgPlayPause; -exports.VgPlaybackButton = require('./lib/vg-controls/vg-playback-button/vg-playback-button').VgPlaybackButton; -exports.VgScrubBar = require('./lib/vg-controls/vg-scrub-bar/vg-scrub-bar').VgScrubBar; -exports.VgScrubBarBufferingTime = require('./lib/vg-controls/vg-scrub-bar/vg-scrub-bar-buffering-time/vg-scrub-bar-buffering-time').VgScrubBarBufferingTime; -exports.VgScrubBarCurrentTime = require('./lib/vg-controls/vg-scrub-bar/vg-scrub-bar-current-time/vg-scrub-bar-current-time').VgScrubBarCurrentTime; +exports.VgControls = require('./dist/vg-controls/vg-controls').VgControls; +exports.VgFullscreen = require('./dist/vg-controls/vg-fullscreen/vg-fullscreen').VgFullscreen; +exports.VgMute = require('./dist/vg-controls/vg-mute/vg-mute').VgMute; +exports.VgPlayPause = require('./dist/vg-controls/vg-play-pause/vg-play-pause').VgPlayPause; +exports.VgPlaybackButton = require('./dist/vg-controls/vg-playback-button/vg-playback-button').VgPlaybackButton; +exports.VgScrubBar = require('./dist/vg-controls/vg-scrub-bar/vg-scrub-bar').VgScrubBar; +exports.VgScrubBarBufferingTime = require('./dist/vg-controls/vg-scrub-bar/vg-scrub-bar-buffering-time/vg-scrub-bar-buffering-time').VgScrubBarBufferingTime; +exports.VgScrubBarCurrentTime = require('./dist/vg-controls/vg-scrub-bar/vg-scrub-bar-current-time/vg-scrub-bar-current-time').VgScrubBarCurrentTime; -exports.VgOverlayPlay = require('./lib/vg-overlay-play/vg-overlay-play').VgOverlayPlay; +exports.VgOverlayPlay = require('./dist/vg-overlay-play/vg-overlay-play').VgOverlayPlay; -exports.VgEvents = require('./lib/events/vg-events').VgEvents; +exports.VgEvents = require('./dist/events/vg-events').VgEvents; -exports.VgAPI = require('./lib/services/vg-api').VgAPI; -exports.VgFullscreenAPI = require('./lib/services/vg-fullscreen-api').VgFullscreenAPI; +exports.VgAPI = require('./dist/services/vg-api').VgAPI; +exports.VgFullscreenAPI = require('./dist/services/vg-fullscreen-api').VgFullscreenAPI;