From d778ab7118f7f9b095fcb7ac10966ece0909f441 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Wed, 15 Jan 2014 15:20:54 +0200 Subject: [PATCH] Added Jasmine test for initial retrieval of duration. BLD-529. --- .../js/spec/video/video_player_spec.js | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js index 8bba963b58..47ddf7d57d 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js @@ -876,12 +876,39 @@ }); describe('getDuration', function () { - beforeEach(function () { + var oldYT; + beforeEach(function () { + oldYT = window.YT; + + jasmine.stubRequests(); + + window.YT = { + Player: function () { + return { getDuration: function () { return 60; } }; + }, + PlayerState: oldYT.PlayerState, + ready: function (callback) { + callback(); + } + }; + + spyOn(window.YT, 'Player').andCallThrough(); + + initializeYouTube(); + + spyOn(state, 'getDuration').andCallThrough(); + spyOn(state.videoPlayer.player, 'getDuration').andReturn(0); + }); + + afterEach(function () { + window.YT = oldYT; }); it('getDuration is called as a fall-back', function () { + state.videoPlayer.duration(); + expect(state.getDuration).toHaveBeenCalled(); }); });