Commit cec1b23d by Prem Sichanugrist

Remove mystery guest from the test

parent 0815f349
jasmine.getFixtures().fixturesPath = "/_jasmine/fixtures/" jasmine.getFixtures().fixturesPath = "/_jasmine/fixtures/"
jasmine.stubbedMetadata = jasmine.stubbedMetadata =
abc123: slowerSpeedYoutubeId:
id: 'abc123' id: 'slowerSpeedYoutubeId'
duration: 100 duration: 300
def456: normalSpeedYoutubeId:
id: 'def456' id: 'normalSpeedYoutubeId'
duration: 200 duration: 200
bogus: bogus:
duration: 300 duration: 100
jasmine.stubbedCaption = jasmine.stubbedCaption =
start: [0, 10000, 20000, 30000] start: [0, 10000, 20000, 30000]
...@@ -49,7 +49,7 @@ jasmine.stubVideoPlayer = (context, enableParts, createPlayer=true) -> ...@@ -49,7 +49,7 @@ jasmine.stubVideoPlayer = (context, enableParts, createPlayer=true) ->
loadFixtures 'video.html' loadFixtures 'video.html'
jasmine.stubRequests() jasmine.stubRequests()
YT.Player = undefined YT.Player = undefined
context.video = new Video 'example', '.75:abc123,1.0:def456' context.video = new Video 'example', '.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
jasmine.stubYoutubePlayer() jasmine.stubYoutubePlayer()
if createPlayer if createPlayer
return new VideoPlayer(video: context.video) return new VideoPlayer(video: context.video)
......
...@@ -27,7 +27,7 @@ describe 'VideoPlayer', -> ...@@ -27,7 +27,7 @@ describe 'VideoPlayer', ->
expect(window.VideoControl).toHaveBeenCalledWith el: $('.video-controls', @player.el) expect(window.VideoControl).toHaveBeenCalledWith el: $('.video-controls', @player.el)
it 'create video caption', -> it 'create video caption', ->
expect(window.VideoCaption).toHaveBeenCalledWith el: @player.el, youtubeId: 'def456', currentSpeed: '1.0' expect(window.VideoCaption).toHaveBeenCalledWith el: @player.el, youtubeId: 'normalSpeedYoutubeId', currentSpeed: '1.0'
it 'create video speed control', -> it 'create video speed control', ->
expect(window.VideoSpeedControl).toHaveBeenCalledWith el: $('.secondary-controls', @player.el), speeds: ['0.75', '1.0'], currentSpeed: '1.0' expect(window.VideoSpeedControl).toHaveBeenCalledWith el: $('.secondary-controls', @player.el), speeds: ['0.75', '1.0'], currentSpeed: '1.0'
...@@ -43,7 +43,7 @@ describe 'VideoPlayer', -> ...@@ -43,7 +43,7 @@ describe 'VideoPlayer', ->
rel: 0 rel: 0
showinfo: 0 showinfo: 0
enablejsapi: 1 enablejsapi: 1
videoId: 'def456' videoId: 'normalSpeedYoutubeId'
events: events:
onReady: @player.onReady onReady: @player.onReady
onStateChange: @player.onStateChange onStateChange: @player.onStateChange
...@@ -153,7 +153,7 @@ describe 'VideoPlayer', -> ...@@ -153,7 +153,7 @@ describe 'VideoPlayer', ->
@player.onStateChange data: YT.PlayerState.PLAYING @player.onStateChange data: YT.PlayerState.PLAYING
it 'log the play_video event', -> it 'log the play_video event', ->
expect(@video.log).toHaveBeenCalledWith 'play_video', id: @player.currentTime, code: 'embedCode' expect(@video.log).toHaveBeenCalledWith 'play_video'
it 'pause other video player', -> it 'pause other video player', ->
expect(@anotherPlayer.pauseVideo).toHaveBeenCalled() expect(@anotherPlayer.pauseVideo).toHaveBeenCalled()
...@@ -187,7 +187,7 @@ describe 'VideoPlayer', -> ...@@ -187,7 +187,7 @@ describe 'VideoPlayer', ->
@player.onStateChange data: YT.PlayerState.PAUSED @player.onStateChange data: YT.PlayerState.PAUSED
it 'log the pause_video event', -> it 'log the pause_video event', ->
expect(@video.log).toHaveBeenCalledWith 'pause_video' expect(@video.log).toHaveBeenCalledWith 'pause_video'
it 'set current video player as inactive', -> it 'set current video player as inactive', ->
expect(window.player).toBeNull() expect(window.player).toBeNull()
...@@ -270,7 +270,7 @@ describe 'VideoPlayer', -> ...@@ -270,7 +270,7 @@ describe 'VideoPlayer', ->
@player.onSpeedChange {}, '0.75' @player.onSpeedChange {}, '0.75'
it 'load the video', -> it 'load the video', ->
expect(@player.player.loadVideoById).toHaveBeenCalledWith 'abc123', '80.000' expect(@player.player.loadVideoById).toHaveBeenCalledWith 'slowerSpeedYoutubeId', '80.000'
it 'trigger updatePlayTime event', -> it 'trigger updatePlayTime event', ->
expect(@player.updatePlayTime).toHaveBeenCalledWith '80.000' expect(@player.updatePlayTime).toHaveBeenCalledWith '80.000'
...@@ -281,7 +281,7 @@ describe 'VideoPlayer', -> ...@@ -281,7 +281,7 @@ describe 'VideoPlayer', ->
@player.onSpeedChange {}, '0.75' @player.onSpeedChange {}, '0.75'
it 'cue the video', -> it 'cue the video', ->
expect(@player.player.cueVideoById).toHaveBeenCalledWith 'abc123', '80.000' expect(@player.player.cueVideoById).toHaveBeenCalledWith 'slowerSpeedYoutubeId', '80.000'
it 'trigger updatePlayTime event', -> it 'trigger updatePlayTime event', ->
expect(@player.updatePlayTime).toHaveBeenCalledWith '80.000' expect(@player.updatePlayTime).toHaveBeenCalledWith '80.000'
......
...@@ -3,6 +3,10 @@ describe 'Video', -> ...@@ -3,6 +3,10 @@ describe 'Video', ->
loadFixtures 'video.html' loadFixtures 'video.html'
jasmine.stubRequests() jasmine.stubRequests()
@videosDefinition = '.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
@slowerSpeedYoutubeId = 'slowerSpeedYoutubeId'
@normalSpeedYoutubeId = 'normalSpeedYoutubeId'
afterEach -> afterEach ->
window.player = undefined window.player = undefined
window.onYouTubePlayerAPIReady = undefined window.onYouTubePlayerAPIReady = undefined
...@@ -15,7 +19,7 @@ describe 'Video', -> ...@@ -15,7 +19,7 @@ describe 'Video', ->
describe 'by default', -> describe 'by default', ->
beforeEach -> beforeEach ->
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
it 'reset the current video player', -> it 'reset the current video player', ->
expect(window.player).toBeNull() expect(window.player).toBeNull()
...@@ -25,16 +29,16 @@ describe 'Video', -> ...@@ -25,16 +29,16 @@ describe 'Video', ->
it 'parse the videos', -> it 'parse the videos', ->
expect(@video.videos).toEqual expect(@video.videos).toEqual
'0.75': 'abc123' '0.75': @slowerSpeedYoutubeId
'1.0': 'def456' '1.0': @normalSpeedYoutubeId
it 'fetch the video metadata', -> it 'fetch the video metadata', ->
expect(@video.metadata).toEqual expect(@video.metadata).toEqual
abc123: slowerSpeedYoutubeId:
id: 'abc123' id: @slowerSpeedYoutubeId
duration: 100 duration: 300
def456: normalSpeedYoutubeId:
id: 'def456' id: @normalSpeedYoutubeId
duration: 200 duration: 200
it 'parse available video speeds', -> it 'parse available video speeds', ->
...@@ -51,7 +55,7 @@ describe 'Video', -> ...@@ -51,7 +55,7 @@ describe 'Video', ->
@originalYT = window.YT @originalYT = window.YT
window.YT = { Player: true } window.YT = { Player: true }
spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer) spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer)
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
afterEach -> afterEach ->
window.YT = @originalYT window.YT = @originalYT
...@@ -64,7 +68,7 @@ describe 'Video', -> ...@@ -64,7 +68,7 @@ describe 'Video', ->
beforeEach -> beforeEach ->
@originalYT = window.YT @originalYT = window.YT
window.YT = {} window.YT = {}
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
afterEach -> afterEach ->
window.YT = @originalYT window.YT = @originalYT
...@@ -77,7 +81,7 @@ describe 'Video', -> ...@@ -77,7 +81,7 @@ describe 'Video', ->
@originalYT = window.YT @originalYT = window.YT
window.YT = {} window.YT = {}
spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer) spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer)
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
window.onYouTubePlayerAPIReady() window.onYouTubePlayerAPIReady()
afterEach -> afterEach ->
...@@ -90,20 +94,20 @@ describe 'Video', -> ...@@ -90,20 +94,20 @@ describe 'Video', ->
describe 'youtubeId', -> describe 'youtubeId', ->
beforeEach -> beforeEach ->
$.cookie.andReturn '1.0' $.cookie.andReturn '1.0'
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
describe 'with speed', -> describe 'with speed', ->
it 'return the video id for given speed', -> it 'return the video id for given speed', ->
expect(@video.youtubeId('0.75')).toEqual 'abc123' expect(@video.youtubeId('0.75')).toEqual @slowerSpeedYoutubeId
expect(@video.youtubeId('1.0')).toEqual 'def456' expect(@video.youtubeId('1.0')).toEqual @normalSpeedYoutubeId
describe 'without speed', -> describe 'without speed', ->
it 'return the video id for current speed', -> it 'return the video id for current speed', ->
expect(@video.youtubeId()).toEqual 'def456' expect(@video.youtubeId()).toEqual @normalSpeedYoutubeId
describe 'setSpeed', -> describe 'setSpeed', ->
beforeEach -> beforeEach ->
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
describe 'when new speed is available', -> describe 'when new speed is available', ->
beforeEach -> beforeEach ->
...@@ -124,14 +128,14 @@ describe 'Video', -> ...@@ -124,14 +128,14 @@ describe 'Video', ->
describe 'getDuration', -> describe 'getDuration', ->
beforeEach -> beforeEach ->
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
it 'return duration for current video', -> it 'return duration for current video', ->
expect(@video.getDuration()).toEqual 200 expect(@video.getDuration()).toEqual 200
describe 'log', -> describe 'log', ->
beforeEach -> beforeEach ->
@video = new Video 'example', '.75:abc123,1.0:def456' @video = new Video 'example', @videosDefinition
@video.setSpeed '1.0' @video.setSpeed '1.0'
spyOn Logger, 'log' spyOn Logger, 'log'
@video.player = { currentTime: 25 } @video.player = { currentTime: 25 }
...@@ -140,6 +144,6 @@ describe 'Video', -> ...@@ -140,6 +144,6 @@ describe 'Video', ->
it 'call the logger with valid parameters', -> it 'call the logger with valid parameters', ->
expect(Logger.log).toHaveBeenCalledWith 'someEvent', expect(Logger.log).toHaveBeenCalledWith 'someEvent',
id: 'example' id: 'example'
code: 'def456' code: @normalSpeedYoutubeId
currentTime: 25 currentTime: 25
speed: '1.0' speed: '1.0'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment