Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-barstow committed Mar 8, 2022
1 parent 3b70220 commit b9f39f7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2826,8 +2826,6 @@ QUnit.test('audioOnlyMode(true) returns Promise when promises are supported', fu

if (window.Promise) {
assert.ok(returnValTrue instanceof window.Promise, 'audioOnlyMode(true) returns Promise when supported');
} else {
assert.equal(returnValTrue, undefined, 'audioOnlyMode(true) returns undefined when promises unsupported');
}

return returnValTrue;
Expand All @@ -2841,8 +2839,6 @@ QUnit.test('audioOnlyMode(false) returns Promise when promises are supported', f

if (window.Promise) {
assert.ok(returnValFalse instanceof window.Promise, 'audioOnlyMode(false) returns Promise when supported');
} else {
assert.equal(returnValFalse, undefined, 'audioOnlyMode(false) returns undefined when promises unsupported');
}

return returnValFalse;
Expand All @@ -2855,6 +2851,25 @@ QUnit.test('audioOnlyMode() getter returns Boolean', function(assert) {
assert.ok(typeof player.audioOnlyMode() === 'boolean', 'getter correctly returns boolean');
});

QUnit.test('audioOnlyMode(true/false) is synchronous and returns undefined when promises are unsupported', function(assert) {
const originalPromise = window.Promise;
const player = TestHelpers.makePlayer({});

window.Promise = undefined;

const returnValTrue = player.audioOnlyMode(true);

assert.equal(returnValTrue, undefined, 'return value is undefined');
assert.ok(player.audioOnlyMode(), 'state synchronously set to true');

const returnValFalse = player.audioOnlyMode(false);

assert.equal(returnValFalse, undefined, 'return value is undefined');
assert.notOk(player.audioOnlyMode(), 'state synchronously set to false');

window.Promise = originalPromise;
});

QUnit.test('audioOnlyMode() gets the correct audioOnlyMode state', function(assert) {
const player = TestHelpers.makePlayer({});

Expand Down

0 comments on commit b9f39f7

Please sign in to comment.