Skip to content

Commit

Permalink
Switched 'created' event for 'ready' event so that it runs after is i…
Browse files Browse the repository at this point in the history
…nserted into the document.
  • Loading branch information
MKRazz committed Aug 18, 2016
1 parent 0cdc2e5 commit 15549c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/vue-youtube-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const YouTubePlayer = {
this.player[name](videoId)
}
},
created() {
ready() {
container.register((YouTube) => {
const {
playerHeight : height = '390',
Expand Down
24 changes: 12 additions & 12 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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')
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 15549c1

Please sign in to comment.