Commit e381adbc by Anton Stupak

Make js unit tests out of Alpha.

parent 8ba94bb2
<div class="course-content"> <div class="course-content">
<div id="video_example"> <div id="video_example">
<div id="example"> <div id="example">
<div id="video_id" class="video" <div
data-youtube-id-0-75="7tqY6eQzVhE" id="video_id"
data-youtube-id-1-0="cogebirgzzM" class="video"
data-streams="0.75:7tqY6eQzVhE,1.0:cogebirgzzM"
data-show-captions="true" data-show-captions="true"
data-start="" data-start=""
data-end="" data-end=""
data-caption-asset-path="/static/subs/"> data-caption-asset-path="/static/subs/"
data-autoplay="False"
>
<div class="tc-wrapper"> <div class="tc-wrapper">
<article class="video-wrapper"> <article class="video-wrapper">
<div class="video-player-pre"></div>
<section class="video-player"> <section class="video-player">
<div id="id"></div> <div id="id"></div>
</section> </section>
<section class="video-controls"></section> <div class="video-player-post"></div>
<section class="video-controls">
<div class="slider"></div>
<div>
<ul class="vcr">
<li><a class="video_control" href="#" title="Play"></a></li>
<li><div class="vidtime">0:00 / 0:00</div></li>
</ul>
<div class="secondary-controls">
<div class="speeds">
<a href="#">
<h3>Speed</h3>
<p class="active"></p>
</a>
<ol class="video_speeds"></ol>
</div>
<div class="volume">
<a href="#"></a>
<div class="volume-slider-container">
<div class="volume-slider"></div>
</div>
</div>
<a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
<a href="#" class="quality_control" title="HD">HD</a>
<a href="#" class="hide-subtitles" title="Turn off captions">Captions</a>
</div>
</div>
</section>
</article> </article>
<ol class="subtitles"><li></li></ol>
</div> </div>
</div> </div>
</div> </div>
......
<div class="course-content">
<div id="video_example">
<div id="example">
<div
id="video_id"
class="videoalpha"
data-streams="0.75:7tqY6eQzVhE,1.0:cogebirgzzM"
data-show-captions="true"
data-start=""
data-end=""
data-caption-asset-path="/static/subs/"
data-autoplay="False"
>
<div class="tc-wrapper">
<article class="video-wrapper">
<div class="video-player-pre"></div>
<section class="video-player">
<div id="id"></div>
</section>
<div class="video-player-post"></div>
<section class="video-controls">
<div class="slider"></div>
<div>
<ul class="vcr">
<li><a class="video_control" href="#" title="Play"></a></li>
<li><div class="vidtime">0:00 / 0:00</div></li>
</ul>
<div class="secondary-controls">
<div class="speeds">
<a href="#">
<h3>Speed</h3>
<p class="active"></p>
</a>
<ol class="video_speeds"></ol>
</div>
<div class="volume">
<a href="#"></a>
<div class="volume-slider-container">
<div class="volume-slider"></div>
</div>
</div>
<a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
<a href="#" class="quality_control" title="HD">HD</a>
<a href="#" class="hide-subtitles" title="Turn off captions">Captions</a>
</div>
</div>
</section>
</article>
<ol class="subtitles"><li></li></ol>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
*.js *.js
# Tests for videoalpha are written in pure JavaScript. # Tests for video are written in pure JavaScript.
!videoalpha/*.js !video/*.js
...@@ -111,19 +111,18 @@ jasmine.stubYoutubePlayer = -> ...@@ -111,19 +111,18 @@ jasmine.stubYoutubePlayer = ->
obj['getAvailablePlaybackRates'] = jasmine.createSpy('getAvailablePlaybackRates').andReturn [0.75, 1.0, 1.25, 1.5] obj['getAvailablePlaybackRates'] = jasmine.createSpy('getAvailablePlaybackRates').andReturn [0.75, 1.0, 1.25, 1.5]
obj obj
jasmine.stubVideoPlayerAlpha = (context, enableParts, html5=false) -> jasmine.stubVideoPlayer = (context, enableParts, html5=false) ->
console.log('stubVideoPlayerAlpha called')
suite = context.suite suite = context.suite
currentPartName = suite.description while suite = suite.parentSuite currentPartName = suite.description while suite = suite.parentSuite
if html5 == false if html5 == false
loadFixtures 'videoalpha.html' loadFixtures 'video.html'
else else
loadFixtures 'videoalpha_html5.html' loadFixtures 'video_html5.html'
jasmine.stubRequests() jasmine.stubRequests()
YT.Player = undefined YT.Player = undefined
window.OldVideoPlayerAlpha = undefined window.OldVideoPlayer = undefined
jasmine.stubYoutubePlayer() jasmine.stubYoutubePlayer()
return new VideoAlpha '#example', '.75:7tqY6eQzVhE,1.0:cogebirgzzM' return new Video '#example', '.75:7tqY6eQzVhE,1.0:cogebirgzzM'
# Stub jQuery.cookie # Stub jQuery.cookie
......
(function () { (function () {
xdescribe('VideoAlpha', function () { xdescribe('Video', function () {
var oldOTBD; var oldOTBD;
beforeEach(function () { beforeEach(function () {
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
}); });
afterEach(function () { afterEach(function () {
window.OldVideoPlayerAlpha = undefined; window.OldVideoPlayer = undefined;
window.onYouTubePlayerAPIReady = undefined; window.onYouTubePlayerAPIReady = undefined;
window.onHTML5PlayerAPIReady = undefined; window.onHTML5PlayerAPIReady = undefined;
$('source').remove(); $('source').remove();
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
describe('constructor', function () { describe('constructor', function () {
describe('YT', function () { describe('YT', function () {
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha.html'); loadFixtures('video.html');
$.cookie.andReturn('0.75'); $.cookie.andReturn('0.75');
}); });
describe('by default', function () { describe('by default', function () {
beforeEach(function () { beforeEach(function () {
this.state = new window.VideoAlpha('#example'); this.state = new window.Video('#example');
}); });
it('check videoType', function () { it('check videoType', function () {
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
}); });
it('reset the current video player', function () { it('reset the current video player', function () {
expect(window.OldVideoPlayerAlpha).toBeUndefined(); expect(window.OldVideoPlayer).toBeUndefined();
}); });
it('set the elements', function () { it('set the elements', function () {
...@@ -64,14 +64,14 @@ ...@@ -64,14 +64,14 @@
var state; var state;
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha_html5.html'); loadFixtures('video_html5.html');
this.stubVideoPlayerAlpha = jasmine.createSpy('VideoPlayerAlpha'); this.stubVideoPlayer = jasmine.createSpy('VideoPlayer');
$.cookie.andReturn('0.75'); $.cookie.andReturn('0.75');
}); });
describe('by default', function () { describe('by default', function () {
beforeEach(function () { beforeEach(function () {
state = new window.VideoAlpha('#example'); state = new window.Video('#example');
}); });
afterEach(function () { afterEach(function () {
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
}); });
it('reset the current video player', function () { it('reset the current video player', function () {
expect(window.OldVideoPlayerAlpha).toBeUndefined(); expect(window.OldVideoPlayer).toBeUndefined();
}); });
it('set the elements', function () { it('set the elements', function () {
...@@ -104,8 +104,8 @@ ...@@ -104,8 +104,8 @@
it('parse the videos if subtitles do not exist', function () { it('parse the videos if subtitles do not exist', function () {
var sub = ''; var sub = '';
$('#example').find('.videoalpha').data('sub', ''); $('#example').find('.video').data('sub', '');
state = new window.VideoAlpha('#example'); state = new window.Video('#example');
expect(state.videos).toEqual({ expect(state.videos).toEqual({
'0.75': sub, '0.75': sub,
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
// is required. // is required.
describe('HTML5 API is available', function () { describe('HTML5 API is available', function () {
beforeEach(function () { beforeEach(function () {
state = new VideoAlpha('#example'); state = new Video('#example');
}); });
afterEach(function () { afterEach(function () {
...@@ -158,9 +158,9 @@ ...@@ -158,9 +158,9 @@
describe('youtubeId', function () { describe('youtubeId', function () {
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha.html'); loadFixtures('video.html');
$.cookie.andReturn('1.0'); $.cookie.andReturn('1.0');
state = new VideoAlpha('#example'); state = new Video('#example');
}); });
describe('with speed', function () { describe('with speed', function () {
...@@ -180,8 +180,8 @@ ...@@ -180,8 +180,8 @@
describe('setSpeed', function () { describe('setSpeed', function () {
describe('YT', function () { describe('YT', function () {
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha.html'); loadFixtures('video.html');
state = new VideoAlpha('#example'); state = new Video('#example');
}); });
describe('when new speed is available', function () { describe('when new speed is available', function () {
...@@ -214,8 +214,8 @@ ...@@ -214,8 +214,8 @@
describe('HTML5', function () { describe('HTML5', function () {
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha_html5.html'); loadFixtures('video_html5.html');
state = new VideoAlpha('#example'); state = new Video('#example');
}); });
describe('when new speed is available', function () { describe('when new speed is available', function () {
...@@ -249,8 +249,8 @@ ...@@ -249,8 +249,8 @@
describe('getDuration', function () { describe('getDuration', function () {
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha.html'); loadFixtures('video.html');
state = new VideoAlpha('#example'); state = new Video('#example');
}); });
it('return duration for current video', function () { it('return duration for current video', function () {
...@@ -260,8 +260,8 @@ ...@@ -260,8 +260,8 @@
describe('log', function () { describe('log', function () {
beforeEach(function () { beforeEach(function () {
loadFixtures('videoalpha_html5.html'); loadFixtures('video_html5.html');
state = new VideoAlpha('#example'); state = new Video('#example');
spyOn(Logger, 'log'); spyOn(Logger, 'log');
state.videoPlayer.log('someEvent', { state.videoPlayer.log('someEvent', {
currentTime: 25, currentTime: 25,
......
(function () { (function () {
xdescribe('VideoAlpha HTML5Video', function () { xdescribe('Video HTML5Video', function () {
var state, player, oldOTBD, playbackRates = [0.75, 1.0, 1.25, 1.5]; var state, player, oldOTBD, playbackRates = [0.75, 1.0, 1.25, 1.5];
function initialize() { function initialize() {
loadFixtures('videoalpha_html5.html'); loadFixtures('video_html5.html');
state = new VideoAlpha('#example'); state = new Video('#example');
player = state.videoPlayer.player; player = state.videoPlayer.player;
} }
......
(function() { (function() {
xdescribe('VideoCaptionAlpha', function() { xdescribe('VideoCaption', function() {
var state, videoPlayer, videoCaption, videoSpeedControl, oldOTBD; var state, videoPlayer, videoCaption, videoSpeedControl, oldOTBD;
function initialize() { function initialize() {
loadFixtures('videoalpha_all.html'); loadFixtures('video_all.html');
state = new VideoAlpha('#example'); state = new Video('#example');
videoPlayer = state.videoPlayer; videoPlayer = state.videoPlayer;
videoCaption = state.videoCaption; videoCaption = state.videoCaption;
videoSpeedControl = state.videoSpeedControl; videoSpeedControl = state.videoSpeedControl;
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
}); });
it('create the caption element', function() { it('create the caption element', function() {
expect($('.videoalpha')).toContain('ol.subtitles'); expect($('.video')).toContain('ol.subtitles');
}); });
it('add caption control to video player', function() { it('add caption control to video player', function() {
expect($('.videoalpha')).toContain('a.hide-subtitles'); expect($('.video')).toContain('a.hide-subtitles');
}); });
it('fetch the caption', function() { it('fetch the caption', function() {
......
(function() { (function() {
xdescribe('VideoControlAlpha', function() { xdescribe('VideoControl', function() {
var state, videoControl, oldOTBD; var state, videoControl, oldOTBD;
function initialize() { function initialize() {
loadFixtures('videoalpha_all.html'); loadFixtures('video_all.html');
state = new VideoAlpha('#example'); state = new Video('#example');
videoControl = state.videoControl; videoControl = state.videoControl;
} }
......
(function() { (function() {
xdescribe('VideoPlayerAlpha', function() { xdescribe('VideoPlayer', function() {
var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl, oldOTBD; var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl, oldOTBD;
function initialize(fixture) { function initialize(fixture) {
if (typeof fixture === 'undefined') { if (typeof fixture === 'undefined') {
loadFixtures('videoalpha_all.html'); loadFixtures('video_all.html');
} else { } else {
loadFixtures(fixture); loadFixtures(fixture);
} }
state = new VideoAlpha('#example'); state = new Video('#example');
videoPlayer = state.videoPlayer; videoPlayer = state.videoPlayer;
player = videoPlayer.player; player = videoPlayer.player;
videoControl = state.videoControl; videoControl = state.videoControl;
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
} }
function initializeYouTube() { function initializeYouTube() {
initialize('videoalpha.html'); initialize('video.html');
} }
beforeEach(function () { beforeEach(function () {
...@@ -71,9 +71,9 @@ ...@@ -71,9 +71,9 @@
expect(videoProgressSlider.el).toHaveClass('slider'); expect(videoProgressSlider.el).toHaveClass('slider');
}); });
// All the toHandleWith() expect tests are not necessary for this version of Video Alpha. // All the toHandleWith() expect tests are not necessary for this version of Video.
// jQuery event system is not used to trigger and invoke methods. This is an artifact from // jQuery event system is not used to trigger and invoke methods. This is an artifact from
// previous version of Video Alpha. // previous version of Video.
}); });
it('create Youtube player', function() { it('create Youtube player', function() {
......
(function() { (function() {
xdescribe('VideoProgressSliderAlpha', function() { xdescribe('VideoProgressSlider', function() {
var state, videoPlayer, videoProgressSlider, oldOTBD; var state, videoPlayer, videoProgressSlider, oldOTBD;
function initialize() { function initialize() {
loadFixtures('videoalpha_all.html'); loadFixtures('video_all.html');
state = new VideoAlpha('#example'); state = new Video('#example');
videoPlayer = state.videoPlayer; videoPlayer = state.videoPlayer;
videoProgressSlider = state.videoProgressSlider; videoProgressSlider = state.videoProgressSlider;
} }
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
expect(videoProgressSlider.slider).toBeUndefined(); expect(videoProgressSlider.slider).toBeUndefined();
// We can't expect $.fn.slider not to have been called, // We can't expect $.fn.slider not to have been called,
// because sliders are used in other parts of VideoAlpha. // because sliders are used in other parts of Video.
}); });
}); });
}); });
......
(function() { (function() {
xdescribe('VideoQualityControlAlpha', function() { xdescribe('VideoQualityControl', function() {
var state, videoControl, videoQualityControl, oldOTBD; var state, videoControl, videoQualityControl, oldOTBD;
function initialize() { function initialize() {
loadFixtures('videoalpha.html'); loadFixtures('video.html');
state = new VideoAlpha('#example'); state = new Video('#example');
videoControl = state.videoControl; videoControl = state.videoControl;
videoQualityControl = state.videoQualityControl; videoQualityControl = state.videoQualityControl;
} }
......
(function() { (function() {
xdescribe('VideoSpeedControlAlpha', function() { xdescribe('VideoSpeedControl', function() {
var state, videoPlayer, videoControl, videoSpeedControl; var state, videoPlayer, videoControl, videoSpeedControl;
function initialize() { function initialize() {
loadFixtures('videoalpha_all.html'); loadFixtures('video_all.html');
state = new VideoAlpha('#example'); state = new Video('#example');
videoPlayer = state.videoPlayer; videoPlayer = state.videoPlayer;
videoControl = state.videoControl; videoControl = state.videoControl;
videoSpeedControl = state.videoSpeedControl; videoSpeedControl = state.videoSpeedControl;
......
(function() { (function() {
xdescribe('VideoVolumeControlAlpha', function() { xdescribe('VideoVolumeControl', function() {
var state, videoControl, videoVolumeControl, oldOTBD; var state, videoControl, videoVolumeControl, oldOTBD;
function initialize() { function initialize() {
loadFixtures('videoalpha_all.html'); loadFixtures('video_all.html');
state = new VideoAlpha('#example'); state = new Video('#example');
videoControl = state.videoControl; videoControl = state.videoControl;
videoVolumeControl = state.videoVolumeControl; videoVolumeControl = state.videoVolumeControl;
} }
......
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