From 15549c18afd6a3d21fa633f543d645481a17befb Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 18 Aug 2016 17:44:55 -0400 Subject: [PATCH] Switched 'created' event for 'ready' event so that it runs after is inserted into the document. --- lib/vue-youtube-embed.js | 2 +- src/index.js | 2 +- test/index.spec.js | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/vue-youtube-embed.js b/lib/vue-youtube-embed.js index 8c486c3..f95a97e 100644 --- a/lib/vue-youtube-embed.js +++ b/lib/vue-youtube-embed.js @@ -197,7 +197,7 @@ var YouTubePlayer = exports.YouTubePlayer = { this.player[name](videoId); } }, - created: function created() { + ready: function ready() { var _this3 = this; container.register(function (YouTube) { diff --git a/src/index.js b/src/index.js index 5cd76ae..a7a15a7 100644 --- a/src/index.js +++ b/src/index.js @@ -119,7 +119,7 @@ export const YouTubePlayer = { this.player[name](videoId) } }, - created() { + ready() { container.register((YouTube) => { const { playerHeight : height = '390', diff --git a/test/index.spec.js b/test/index.spec.js index cfdb0ac..6345eaa 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -155,10 +155,10 @@ describe('YouTubePlayer', () => { }) - describe('#created', () => { + describe('#ready', () => { it('should call container.register', () => { sinon.spy(container, 'register') - YouTubePlayer.created() + YouTubePlayer.ready() assert.ok(container.register.called) container.register.restore() @@ -168,10 +168,10 @@ describe('YouTubePlayer', () => { it('should pass the default values', () => { const videoId = 'videoId' const component = { - created: YouTubePlayer.created, + ready: YouTubePlayer.ready, videoId } - component.created() + component.ready() const {options} = component.player assert.equal(options.videoId, 'videoId') @@ -190,13 +190,13 @@ describe('YouTubePlayer', () => { autoplay: 1 } const component = { - created: YouTubePlayer.created, + ready: YouTubePlayer.ready, videoId, playerWidth, playerHeight, playerVars } - component.created() + component.ready() const {options} = component.player assert.equal(options.videoId, videoId) @@ -212,10 +212,10 @@ describe('YouTubePlayer', () => { context('default', () => { it('should call YT.Player.prototype.cueVideoById()', () => { const component = { - created: YouTubePlayer.created, + ready: YouTubePlayer.ready, update: YouTubePlayer.methods.update } - component.created() + component.ready() sinon.spy(component.player, 'cueVideoById') component.update('videoId') assert.ok(component.player.cueVideoById.called) @@ -225,13 +225,13 @@ describe('YouTubePlayer', () => { context('autoplay is 0', () => { it('should call YT.Player.prototype.cueVideoById()', () => { const component = { - created: YouTubePlayer.created, + ready: YouTubePlayer.ready, update: YouTubePlayer.methods.update, playerVars: { autoplay: 0 } } - component.created() + component.ready() sinon.spy(component.player, 'cueVideoById') component.update('videoId') assert.ok(component.player.cueVideoById.called) @@ -241,13 +241,13 @@ describe('YouTubePlayer', () => { context('autoplay is 1', () => { it('should call YT.Player.prototype.loadVideoById()', () => { const component = { - created: YouTubePlayer.created, + ready: YouTubePlayer.ready, update: YouTubePlayer.methods.update, playerVars: { autoplay: 1 } } - component.created() + component.ready() sinon.spy(component.player, 'loadVideoById') component.update('videoId') assert.ok(component.player.loadVideoById.called)