From 348b037bf2eceeb16953d5517d9e5a2a3ee22fd7 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Fri, 18 Oct 2013 13:15:13 +0300 Subject: [PATCH] Fixing Jasmine tests. Adding tests for start end time checking. --- .../xmodule/js/spec/video/general_spec.js | 72 +++++++++++++++++++ .../js/spec/video/video_player_spec.js | 4 +- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/js/spec/video/general_spec.js b/common/lib/xmodule/xmodule/js/spec/video/general_spec.js index 7803099aa8..e06dc307d1 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/general_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/general_spec.js @@ -184,6 +184,78 @@ }); }); + describe('checking start and end times', function () { + beforeEach(function () { + loadFixtures('video.html'); + + }); + + it('both times are proper', function () { + $('#example').find('.video') + .data({ + 'start': 12, + 'end': 24 + }); + + state = new Video('#example'); + + expect(state.config.start).toBe(12); + expect(state.config.end).toBe(24); + }); + + it('start time is invalid', function () { + $('#example').find('.video') + .data({ + 'start': '', + 'end': 24 + }); + + state = new Video('#example'); + + expect(state.config.start).toBe(0); + expect(state.config.end).toBe(24); + }); + + it('end time is invalid', function () { + $('#example').find('.video') + .data({ + 'start': 12, + 'end': '' + }); + + state = new Video('#example'); + + expect(state.config.start).toBe(12); + expect(state.config.end).toBe(null); + }); + + it('start time is less than 0', function () { + $('#example').find('.video') + .data({ + 'start': -12, + 'end': 24 + }); + + state = new Video('#example'); + + expect(state.config.start).toBe(0); + expect(state.config.end).toBe(24); + }); + + it('start time is greater than end time', function () { + $('#example').find('.video') + .data({ + 'start': 42, + 'end': 24 + }); + + state = new Video('#example'); + + expect(state.config.start).toBe(42); + expect(state.config.end).toBe(null); + }); + }); + describe('multiple YT on page', function () { var state1, state2, state3; 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 988d5bdaec..e21faa4a4a 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 @@ -114,7 +114,9 @@ showinfo: 0, enablejsapi: 1, modestbranding: 1, - html5: 1 + html5: 1, + start: 0, + end: null }, videoId: 'cogebirgzzM', events: {