Skip to content

Commit

Permalink
test(ie8): only run mute toggle tests in html5 env (#4003)
Browse files Browse the repository at this point in the history
IE8 can't run the html5 tech and the mute toggle tests rely on a working
volume and mute functionality which tech faker does not have. Instead of
implementing it in tech faker, skip it on non-html5 environments.
  • Loading branch information
gkatsev authored Jan 31, 2017
1 parent cb42fcf commit 5bde16a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
64 changes: 35 additions & 29 deletions test/unit/controls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Slider from '../../src/js/slider/slider.js';
import FullscreenToggle from '../../src/js/control-bar/fullscreen-toggle.js';
import TestHelpers from './test-helpers.js';
import document from 'global/document';
import Html5 from '../../src/js/tech/html5.js';

QUnit.module('Controls');

Expand Down Expand Up @@ -93,43 +94,48 @@ QUnit.test('Fullscreen control text should be correct when fullscreenchange is t
player.dispose();
});

QUnit.test('Clicking MuteToggle when volume is above 0 should toggle muted property and not change volume', function(assert) {
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
const muteToggle = new MuteToggle(player);
// only run these tests if Html5 is supported.
// IE8 can't run the Html5 tech and to test this functionality otherwith the the tech faker,
// we'd need to implement volume functionality into tech faker
if (Html5.isSupported()) {
QUnit.test('Clicking MuteToggle when volume is above 0 should toggle muted property and not change volume', function(assert) {
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
const muteToggle = new MuteToggle(player);

assert.equal(player.volume(), 1, 'volume is above 0');
assert.equal(player.muted(), false, 'player is not muted');
assert.equal(player.volume(), 1, 'volume is above 0');
assert.equal(player.muted(), false, 'player is not muted');

muteToggle.handleClick();
muteToggle.handleClick();

assert.equal(player.volume(), 1, 'volume is same');
assert.equal(player.muted(), true, 'player is muted');
});
assert.equal(player.volume(), 1, 'volume is same');
assert.equal(player.muted(), true, 'player is muted');
});

QUnit.test('Clicking MuteToggle when volume is 0 and muted is false should set volume to lastVolume and keep muted false', function(assert) {
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
const muteToggle = new MuteToggle(player);
QUnit.test('Clicking MuteToggle when volume is 0 and muted is false should set volume to lastVolume and keep muted false', function(assert) {
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
const muteToggle = new MuteToggle(player);

player.volume(0);
assert.equal(player.lastVolume_(), 1, 'lastVolume is set');
assert.equal(player.muted(), false, 'player is muted');
player.volume(0);
assert.equal(player.lastVolume_(), 1, 'lastVolume is set');
assert.equal(player.muted(), false, 'player is muted');

muteToggle.handleClick();
muteToggle.handleClick();

assert.equal(player.volume(), 1, 'volume is set to lastVolume');
assert.equal(player.muted(), false, 'muted remains false');
});
assert.equal(player.volume(), 1, 'volume is set to lastVolume');
assert.equal(player.muted(), false, 'muted remains false');
});

QUnit.test('Clicking MuteToggle when volume is 0 and muted is true should set volume to lastVolume and sets muted to false', function(assert) {
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
const muteToggle = new MuteToggle(player);
QUnit.test('Clicking MuteToggle when volume is 0 and muted is true should set volume to lastVolume and sets muted to false', function(assert) {
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
const muteToggle = new MuteToggle(player);

player.volume(0);
player.muted(true);
player.lastVolume_(0.5);
player.volume(0);
player.muted(true);
player.lastVolume_(0.5);

muteToggle.handleClick();
muteToggle.handleClick();

assert.equal(player.volume(), 0.5, 'volume is set to lastVolume');
assert.equal(player.muted(), false, 'muted is set to false');
});
assert.equal(player.volume(), 0.5, 'volume is set to lastVolume');
assert.equal(player.muted(), false, 'muted is set to false');
});
}
2 changes: 2 additions & 0 deletions test/unit/tech/tech-faker.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class TechFaker extends Tech {

setVolume(newVolume) {}

setMuted() {}

currentTime() {
return 0;
}
Expand Down

0 comments on commit 5bde16a

Please sign in to comment.