* 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
124 lines
4.3 KiB
JavaScript
124 lines
4.3 KiB
JavaScript
// eslint-disable-next-line no-shadow-restricted-names
|
|
(function(undefined) {
|
|
describe('VideoQualityControl', function() {
|
|
var state, qualityControl, videoPlayer, player;
|
|
|
|
afterEach(function() {
|
|
$('source').remove();
|
|
if (state.storage) {
|
|
state.storage.clear();
|
|
}
|
|
state.videoPlayer.destroy();
|
|
});
|
|
|
|
describe('constructor, YouTube mode', function() {
|
|
beforeEach(function() {
|
|
state = jasmine.initializePlayerYouTube();
|
|
qualityControl = state.videoQualityControl;
|
|
videoPlayer = state.videoPlayer;
|
|
player = videoPlayer.player;
|
|
|
|
// Define empty methods in YouTube stub
|
|
player.quality = 'large';
|
|
player.setPlaybackQuality.and.callFake(function(quality) {
|
|
player.quality = quality;
|
|
});
|
|
});
|
|
|
|
it('contains the quality control and is initially hidden',
|
|
function() {
|
|
expect(qualityControl.el).toHaveClass(
|
|
'quality-control is-hidden'
|
|
);
|
|
});
|
|
|
|
it('add ARIA attributes to quality control', function() {
|
|
expect(qualityControl.el).toHaveAttrs({
|
|
'aria-disabled': 'false'
|
|
});
|
|
});
|
|
|
|
it('bind the quality control', function() {
|
|
expect(qualityControl.el).toHandleWith('click',
|
|
qualityControl.toggleQuality
|
|
);
|
|
|
|
expect(state.el).toHandle('play');
|
|
});
|
|
|
|
it('calls fetchAvailableQualities only once', function() {
|
|
expect(player.getAvailableQualityLevels.calls.count())
|
|
.toEqual(0);
|
|
|
|
videoPlayer.onPlay();
|
|
videoPlayer.onPlay();
|
|
|
|
expect(player.getAvailableQualityLevels.calls.count())
|
|
.toEqual(1);
|
|
});
|
|
|
|
it('initializes with a quality equal to large', function() {
|
|
videoPlayer.onPlay();
|
|
|
|
expect(player.setPlaybackQuality).toHaveBeenCalledWith('large');
|
|
});
|
|
|
|
it('shows the quality control on play if HD is available',
|
|
function() {
|
|
videoPlayer.onPlay();
|
|
|
|
expect(qualityControl.el).not.toHaveClass('is-hidden');
|
|
});
|
|
|
|
it('leaves quality control hidden on play if HD is not available',
|
|
function() {
|
|
player.getAvailableQualityLevels.and.returnValue(
|
|
['large', 'medium', 'small']
|
|
);
|
|
|
|
videoPlayer.onPlay();
|
|
expect(qualityControl.el).toHaveClass('is-hidden');
|
|
});
|
|
|
|
it('switch to HD if it is available', function() {
|
|
videoPlayer.onPlay();
|
|
|
|
qualityControl.quality = 'large';
|
|
qualityControl.el.click();
|
|
expect(player.setPlaybackQuality)
|
|
.toHaveBeenCalledWith('highres');
|
|
|
|
qualityControl.quality = 'highres';
|
|
qualityControl.el.click();
|
|
expect(player.setPlaybackQuality).toHaveBeenCalledWith('large');
|
|
});
|
|
|
|
it('quality control is active if HD is available',
|
|
function() {
|
|
player.getAvailableQualityLevels.and.returnValue(
|
|
['highres', 'hd1080', 'hd720']
|
|
);
|
|
|
|
qualityControl.quality = 'highres';
|
|
|
|
videoPlayer.onPlay();
|
|
expect(qualityControl.el).toHaveClass('active');
|
|
});
|
|
|
|
it('can destroy itself', function() {
|
|
state.videoQualityControl.destroy();
|
|
expect(state.videoQualityControl).toBeUndefined();
|
|
expect($('.quality-control')).not.toExist();
|
|
});
|
|
});
|
|
|
|
describe('constructor, HTML5 mode', function() {
|
|
it('does not contain the quality control', function() {
|
|
state = jasmine.initializePlayer();
|
|
|
|
expect(state.el.find('.quality-control').length).toBe(0);
|
|
});
|
|
});
|
|
});
|
|
}).call(this);
|