1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-14 11:23:30 +02:00
video.js/test/unit/controls.js
David LaPalomento ad98bebf55 Reformat var statements
Declare them in a single line at the top of the function and initialize them later.
2013-03-05 13:38:47 -05:00

79 lines
1.9 KiB
JavaScript

module('Controls');
test('should hide volume control if it\'s not supported', function() {
var noop, player, volumeControl, muteToggle;
noop = function(){};
player = {
id: noop,
on: noop,
ready: noop,
tech: {
features: {
volumeControl: false
}
}
};
volumeControl = new vjs.VolumeControl(player);
muteToggle = new vjs.MuteToggle(player);
equal(volumeControl.el().style.display, 'none', 'volumeControl is not hidden');
equal(muteToggle.el().style.display, 'none', 'muteToggle is not hidden');
});
test('should test and toggle volume control on `loadstart`', function(){
var noop, listeners, player, volumeControl, muteToggle;
noop = function(){};
listeners = [];
player = {
id: noop,
on: function(event, callback){
listeners.push(callback);
},
ready: noop,
volume: function(){
return 1;
},
muted: function(){
return false;
},
tech: {
features: {
volumeControl: true
}
}
};
volumeControl = new vjs.VolumeControl(player);
muteToggle = new vjs.MuteToggle(player);
equal(volumeControl.el().style.display,
'',
'volumeControl is hidden initially');
equal(muteToggle.el().style.display,
'',
'muteToggle is hidden initially');
player.tech.features.volumeControl = false;
listeners.forEach(function(listener) {
listener();
});
equal(volumeControl.el().style.display,
'none',
'volumeControl does not hide itself');
equal(muteToggle.el().style.display,
'none',
'muteToggle does not hide itself');
player.tech.features.volumeControl = true;
listeners.forEach(function(listener) {
listener();
});
equal(volumeControl.el().style.display,
'block',
'volumeControl does not show itself');
equal(muteToggle.el().style.display,
'block',
'muteToggle does not show itself');
});