Files
edx-platform/xmodule/js/spec/video/video_bumper_spec.js
Syed Ali Abbas Zaidi 8480dbc228 chore: apply amnesty on existing not fixable issues (#32215)
* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* chore: apply amnesty on all existing issues

* fix: failing xss-lint issues

* refactor: apply amnesty on remaining issues

* refactor: apply amnesty on new issues

* fix: remove file level suppressions

* refactor: apply amnesty on new issues
2023-08-07 19:13:19 +05:00

109 lines
4.3 KiB
JavaScript

(function(WAIT_TIMEOUT) {
'use strict';
describe('VideoBumper', function() {
var state, oldOTBD, waitForPlaying;
// eslint-disable-next-line no-shadow
waitForPlaying = function(state, done) {
jasmine.waitUntil(function() {
return state.el.hasClass('is-playing');
}).done(done);
};
beforeEach(function() {
oldOTBD = window.onTouchBasedDevice;
window.onTouchBasedDevice = jasmine
.createSpy('onTouchBasedDevice').and.returnValue(null);
state = jasmine.initializePlayer('video_with_bumper.html');
$('.poster .btn-play').click();
jasmine.clock().install();
});
afterEach(function() {
$('source').remove();
state.storage.clear();
if (state.bumperState && state.bumperState.videoPlayer) {
state.bumperState.videoPlayer.destroy();
}
if (state.videoPlayer) {
state.videoPlayer.destroy();
}
window.onTouchBasedDevice = oldOTBD;
jasmine.clock().uninstall();
});
it('can render the bumper video', function() {
expect($('.is-bumper')).toExist();
});
it('can show the main video on error', function(done) {
state.el.triggerHandler('error');
jasmine.clock().tick(20);
expect($('.is-bumper')).not.toExist();
waitForPlaying(state, done);
});
it('can show the main video once bumper ends', function(done) {
state.el.trigger('ended');
jasmine.clock().tick(20);
expect($('.is-bumper')).not.toExist();
waitForPlaying(state, done);
});
it('can show the main video on skip', function(done) {
state.bumperState.videoBumper.skip();
jasmine.clock().tick(20);
expect($('.is-bumper')).not.toExist();
waitForPlaying(state, done);
});
it('can stop the bumper video playing if it is too long', function(done) {
state.el.trigger('timeupdate', [state.bumperState.videoBumper.maxBumperDuration + 1]);
jasmine.clock().tick(20);
expect($('.is-bumper')).not.toExist();
waitForPlaying(state, done);
});
it('can save appropriate states correctly on ended', function() {
var saveState = jasmine.createSpy('saveState');
state.bumperState.videoSaveStatePlugin.saveState = saveState;
state.el.trigger('ended');
jasmine.clock().tick(20);
expect(saveState).toHaveBeenCalledWith(true, {bumper_last_view_date: true});
});
it('can save appropriate states correctly on skip', function() {
var saveState = jasmine.createSpy('saveState');
state.bumperState.videoSaveStatePlugin.saveState = saveState;
state.bumperState.videoBumper.skip();
expect(state.storage.getItem('isBumperShown')).toBeTruthy();
jasmine.clock().tick(20);
expect(saveState).toHaveBeenCalledWith(true, {bumper_last_view_date: true});
});
it('can save appropriate states correctly on error', function() {
var saveState = jasmine.createSpy('saveState');
state.bumperState.videoSaveStatePlugin.saveState = saveState;
state.el.triggerHandler('error');
expect(state.storage.getItem('isBumperShown')).toBeTruthy();
jasmine.clock().tick(20);
expect(saveState).toHaveBeenCalledWith(true, {bumper_last_view_date: true});
});
it('can save appropriate states correctly on skip and do not show again', function() {
var saveState = jasmine.createSpy('saveState');
state.bumperState.videoSaveStatePlugin.saveState = saveState;
state.bumperState.videoBumper.skipAndDoNotShowAgain();
expect(state.storage.getItem('isBumperShown')).toBeTruthy();
jasmine.clock().tick(20);
expect(saveState).toHaveBeenCalledWith(true, {bumper_last_view_date: true, bumper_do_not_show_again: true});
});
it('can destroy itself', function() {
state.bumperState.videoBumper.destroy();
expect(state.videoBumper).toBeUndefined();
});
});
}).call(this, window.WAIT_TIMEOUT);