Skip to content

Commit

Permalink
add a small test for the TimeRange iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Jul 27, 2021
1 parent e2c961a commit f291a11
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/unit/utils/time-ranges.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env qunit */
import { createTimeRanges, createTimeRange } from '../../../src/js/utils/time-ranges.js';
import window from 'global/window';

QUnit.module('time-ranges');

Expand Down Expand Up @@ -76,3 +77,21 @@ QUnit.test('should throw without being given an index', function(assert) {
'end throws if no index is given'
);
});

let testOrSkip = 'skip';

if (window.Symbol && window.Symbol.iterator) {
testOrSkip = 'test';
}
QUnit[testOrSkip]('Array.from works on our time ranges object', function(assert) {
const trRepresentation = [
[0, 10],
[20, 30]
];
let tr = createTimeRanges(trRepresentation);

assert.deepEqual(Array.from(tr), trRepresentation, 'we got back what we put in');

tr = createTimeRanges(0, 10);
assert.deepEqual(Array.from(tr), [[0, 10]], 'we got back a ranges representation');
});

0 comments on commit f291a11

Please sign in to comment.