Make js unit tests out of Alpha.
This commit is contained in:
@@ -1,20 +1,53 @@
|
||||
<div class="course-content">
|
||||
<div id="video_example">
|
||||
<div id="example">
|
||||
<div id="video_id" class="video"
|
||||
data-youtube-id-0-75="7tqY6eQzVhE"
|
||||
data-youtube-id-1-0="cogebirgzzM"
|
||||
<div
|
||||
id="video_id"
|
||||
class="video"
|
||||
data-streams="0.75:7tqY6eQzVhE,1.0:cogebirgzzM"
|
||||
data-show-captions="true"
|
||||
data-start=""
|
||||
data-end=""
|
||||
data-caption-asset-path="/static/subs/">
|
||||
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>
|
||||
<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>
|
||||
|
||||
<ol class="subtitles"><li></li></ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<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>
|
||||
@@ -1,4 +1,4 @@
|
||||
*.js
|
||||
|
||||
# Tests for videoalpha are written in pure JavaScript.
|
||||
!videoalpha/*.js
|
||||
# Tests for video are written in pure JavaScript.
|
||||
!video/*.js
|
||||
|
||||
@@ -111,19 +111,18 @@ jasmine.stubYoutubePlayer = ->
|
||||
obj['getAvailablePlaybackRates'] = jasmine.createSpy('getAvailablePlaybackRates').andReturn [0.75, 1.0, 1.25, 1.5]
|
||||
obj
|
||||
|
||||
jasmine.stubVideoPlayerAlpha = (context, enableParts, html5=false) ->
|
||||
console.log('stubVideoPlayerAlpha called')
|
||||
jasmine.stubVideoPlayer = (context, enableParts, html5=false) ->
|
||||
suite = context.suite
|
||||
currentPartName = suite.description while suite = suite.parentSuite
|
||||
if html5 == false
|
||||
loadFixtures 'videoalpha.html'
|
||||
loadFixtures 'video.html'
|
||||
else
|
||||
loadFixtures 'videoalpha_html5.html'
|
||||
loadFixtures 'video_html5.html'
|
||||
jasmine.stubRequests()
|
||||
YT.Player = undefined
|
||||
window.OldVideoPlayerAlpha = undefined
|
||||
window.OldVideoPlayer = undefined
|
||||
jasmine.stubYoutubePlayer()
|
||||
return new VideoAlpha '#example', '.75:7tqY6eQzVhE,1.0:cogebirgzzM'
|
||||
return new Video '#example', '.75:7tqY6eQzVhE,1.0:cogebirgzzM'
|
||||
|
||||
|
||||
# Stub jQuery.cookie
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(function () {
|
||||
xdescribe('VideoAlpha', function () {
|
||||
xdescribe('Video', function () {
|
||||
var oldOTBD;
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -12,7 +12,7 @@
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
window.OldVideoPlayerAlpha = undefined;
|
||||
window.OldVideoPlayer = undefined;
|
||||
window.onYouTubePlayerAPIReady = undefined;
|
||||
window.onHTML5PlayerAPIReady = undefined;
|
||||
$('source').remove();
|
||||
@@ -22,13 +22,13 @@
|
||||
describe('constructor', function () {
|
||||
describe('YT', function () {
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha.html');
|
||||
loadFixtures('video.html');
|
||||
$.cookie.andReturn('0.75');
|
||||
});
|
||||
|
||||
describe('by default', function () {
|
||||
beforeEach(function () {
|
||||
this.state = new window.VideoAlpha('#example');
|
||||
this.state = new window.Video('#example');
|
||||
});
|
||||
|
||||
it('check videoType', function () {
|
||||
@@ -36,7 +36,7 @@
|
||||
});
|
||||
|
||||
it('reset the current video player', function () {
|
||||
expect(window.OldVideoPlayerAlpha).toBeUndefined();
|
||||
expect(window.OldVideoPlayer).toBeUndefined();
|
||||
});
|
||||
|
||||
it('set the elements', function () {
|
||||
@@ -64,14 +64,14 @@
|
||||
var state;
|
||||
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha_html5.html');
|
||||
this.stubVideoPlayerAlpha = jasmine.createSpy('VideoPlayerAlpha');
|
||||
loadFixtures('video_html5.html');
|
||||
this.stubVideoPlayer = jasmine.createSpy('VideoPlayer');
|
||||
$.cookie.andReturn('0.75');
|
||||
});
|
||||
|
||||
describe('by default', function () {
|
||||
beforeEach(function () {
|
||||
state = new window.VideoAlpha('#example');
|
||||
state = new window.Video('#example');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
@@ -83,7 +83,7 @@
|
||||
});
|
||||
|
||||
it('reset the current video player', function () {
|
||||
expect(window.OldVideoPlayerAlpha).toBeUndefined();
|
||||
expect(window.OldVideoPlayer).toBeUndefined();
|
||||
});
|
||||
|
||||
it('set the elements', function () {
|
||||
@@ -104,8 +104,8 @@
|
||||
it('parse the videos if subtitles do not exist', function () {
|
||||
var sub = '';
|
||||
|
||||
$('#example').find('.videoalpha').data('sub', '');
|
||||
state = new window.VideoAlpha('#example');
|
||||
$('#example').find('.video').data('sub', '');
|
||||
state = new window.Video('#example');
|
||||
|
||||
expect(state.videos).toEqual({
|
||||
'0.75': sub,
|
||||
@@ -142,7 +142,7 @@
|
||||
// is required.
|
||||
describe('HTML5 API is available', function () {
|
||||
beforeEach(function () {
|
||||
state = new VideoAlpha('#example');
|
||||
state = new Video('#example');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
@@ -158,9 +158,9 @@
|
||||
|
||||
describe('youtubeId', function () {
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha.html');
|
||||
loadFixtures('video.html');
|
||||
$.cookie.andReturn('1.0');
|
||||
state = new VideoAlpha('#example');
|
||||
state = new Video('#example');
|
||||
});
|
||||
|
||||
describe('with speed', function () {
|
||||
@@ -180,8 +180,8 @@
|
||||
describe('setSpeed', function () {
|
||||
describe('YT', function () {
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video.html');
|
||||
state = new Video('#example');
|
||||
});
|
||||
|
||||
describe('when new speed is available', function () {
|
||||
@@ -214,8 +214,8 @@
|
||||
|
||||
describe('HTML5', function () {
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha_html5.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_html5.html');
|
||||
state = new Video('#example');
|
||||
});
|
||||
|
||||
describe('when new speed is available', function () {
|
||||
@@ -249,8 +249,8 @@
|
||||
|
||||
describe('getDuration', function () {
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video.html');
|
||||
state = new Video('#example');
|
||||
});
|
||||
|
||||
it('return duration for current video', function () {
|
||||
@@ -260,8 +260,8 @@
|
||||
|
||||
describe('log', function () {
|
||||
beforeEach(function () {
|
||||
loadFixtures('videoalpha_html5.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_html5.html');
|
||||
state = new Video('#example');
|
||||
spyOn(Logger, 'log');
|
||||
state.videoPlayer.log('someEvent', {
|
||||
currentTime: 25,
|
||||
@@ -1,10 +1,10 @@
|
||||
(function () {
|
||||
xdescribe('VideoAlpha HTML5Video', function () {
|
||||
xdescribe('Video HTML5Video', function () {
|
||||
var state, player, oldOTBD, playbackRates = [0.75, 1.0, 1.25, 1.5];
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_html5.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_html5.html');
|
||||
state = new Video('#example');
|
||||
player = state.videoPlayer.player;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
xdescribe('VideoCaptionAlpha', function() {
|
||||
xdescribe('VideoCaption', function() {
|
||||
var state, videoPlayer, videoCaption, videoSpeedControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_all.html');
|
||||
state = new Video('#example');
|
||||
videoPlayer = state.videoPlayer;
|
||||
videoCaption = state.videoCaption;
|
||||
videoSpeedControl = state.videoSpeedControl;
|
||||
@@ -33,11 +33,11 @@
|
||||
});
|
||||
|
||||
it('create the caption element', function() {
|
||||
expect($('.videoalpha')).toContain('ol.subtitles');
|
||||
expect($('.video')).toContain('ol.subtitles');
|
||||
});
|
||||
|
||||
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() {
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
xdescribe('VideoControlAlpha', function() {
|
||||
xdescribe('VideoControl', function() {
|
||||
var state, videoControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_all.html');
|
||||
state = new Video('#example');
|
||||
videoControl = state.videoControl;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
(function() {
|
||||
xdescribe('VideoPlayerAlpha', function() {
|
||||
xdescribe('VideoPlayer', function() {
|
||||
var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl, oldOTBD;
|
||||
|
||||
function initialize(fixture) {
|
||||
if (typeof fixture === 'undefined') {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
loadFixtures('video_all.html');
|
||||
} else {
|
||||
loadFixtures(fixture);
|
||||
}
|
||||
|
||||
state = new VideoAlpha('#example');
|
||||
state = new Video('#example');
|
||||
videoPlayer = state.videoPlayer;
|
||||
player = videoPlayer.player;
|
||||
videoControl = state.videoControl;
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
|
||||
function initializeYouTube() {
|
||||
initialize('videoalpha.html');
|
||||
initialize('video.html');
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -71,9 +71,9 @@
|
||||
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
|
||||
// previous version of Video Alpha.
|
||||
// previous version of Video.
|
||||
});
|
||||
|
||||
it('create Youtube player', function() {
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
xdescribe('VideoProgressSliderAlpha', function() {
|
||||
xdescribe('VideoProgressSlider', function() {
|
||||
var state, videoPlayer, videoProgressSlider, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_all.html');
|
||||
state = new Video('#example');
|
||||
videoPlayer = state.videoPlayer;
|
||||
videoProgressSlider = state.videoProgressSlider;
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
expect(videoProgressSlider.slider).toBeUndefined();
|
||||
|
||||
// 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.
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
xdescribe('VideoQualityControlAlpha', function() {
|
||||
xdescribe('VideoQualityControl', function() {
|
||||
var state, videoControl, videoQualityControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video.html');
|
||||
state = new Video('#example');
|
||||
videoControl = state.videoControl;
|
||||
videoQualityControl = state.videoQualityControl;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
xdescribe('VideoSpeedControlAlpha', function() {
|
||||
xdescribe('VideoSpeedControl', function() {
|
||||
var state, videoPlayer, videoControl, videoSpeedControl;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_all.html');
|
||||
state = new Video('#example');
|
||||
videoPlayer = state.videoPlayer;
|
||||
videoControl = state.videoControl;
|
||||
videoSpeedControl = state.videoSpeedControl;
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
xdescribe('VideoVolumeControlAlpha', function() {
|
||||
xdescribe('VideoVolumeControl', function() {
|
||||
var state, videoControl, videoVolumeControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
state = new VideoAlpha('#example');
|
||||
loadFixtures('video_all.html');
|
||||
state = new Video('#example');
|
||||
videoControl = state.videoControl;
|
||||
videoVolumeControl = state.videoVolumeControl;
|
||||
}
|
||||
Reference in New Issue
Block a user