Skip to content

Commit

Permalink
test: add unit tests for player.duration() (#4459)
Browse files Browse the repository at this point in the history
Unit tests for #4443
  • Loading branch information
alex-barstow authored and gkatsev committed Jul 14, 2017
1 parent 7579fc1 commit 1e80e59
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1655,3 +1655,31 @@ QUnit.test('should add a class with major version', function(assert) {

player.dispose();
});

QUnit.test('player.duration() returns NaN if player.cache_.duration is undefined', function(assert) {
const player = TestHelpers.makePlayer();

player.cache_.duration = undefined;
assert.ok(Number.isNaN(player.duration()), 'returned NaN for unkown duration');
});

QUnit.test('player.duration() returns player.cache_.duration if it is defined', function(assert) {
const player = TestHelpers.makePlayer();

player.cache_.duration = 200;
assert.equal(player.duration(), 200, 'returned correct integer duration');
player.cache_.duration = 942;
assert.equal(player.duration(), 942, 'returned correct integer duration');
});

QUnit.test('player.duration() sets the value of player.cache_.duration', function(assert) {
const player = TestHelpers.makePlayer();

// set an arbitrary initial cached duration value for testing the setter functionality
player.cache_.duration = 1;

player.duration(NaN);
assert.ok(Number.isNaN(player.duration()), 'duration() set and get NaN duration value');
player.duration(200);
assert.equal(player.duration(), 200, 'duration() set and get integer duration value');
});

0 comments on commit 1e80e59

Please sign in to comment.