-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@imbcmdth extended createTimeRange to support multiple timeranges. cl…
…oses #2604
- Loading branch information
Showing
4 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import { createTimeRange } from '../../../src/js/utils/time-ranges.js'; | ||
import { createTimeRanges, createTimeRange } from '../../../src/js/utils/time-ranges.js'; | ||
|
||
q.module('time-ranges'); | ||
|
||
test('should create a fake timerange', function(){ | ||
var tr = createTimeRange(0, 10); | ||
ok(tr.start() === 0); | ||
ok(tr.end() === 10); | ||
test('should export the deprecated createTimeRange function', function(){ | ||
equal(createTimeRange, createTimeRanges, 'createTimeRange is an alias to createTimeRanges'); | ||
}); | ||
|
||
test('should create a fake single timerange', function(assert){ | ||
var tr = createTimeRanges(0, 10); | ||
|
||
equal(tr.length, 1, 'length should be 1'); | ||
equal(tr.start(), 0, 'works if start is called with no arguments'); | ||
equal(tr.end(), 10, 'works if end is called with no arguments'); | ||
equal(tr.start(0), 0, 'works if start is called with valid index'); | ||
equal(tr.end(0), 10, 'works if end is called with with valid index'); | ||
assert.throws(()=>tr.start(1), /Failed to execute 'start'/, 'fails if start is called with an invalid index'); | ||
assert.throws(()=>tr.end(1), /Failed to execute 'end'/, 'fails if end is called with with an invalid index'); | ||
}); | ||
|
||
test('should create a fake multiple timerange', function(assert){ | ||
var tr = createTimeRanges([ | ||
[0, 10], | ||
[11, 20] | ||
]); | ||
|
||
equal(tr.length, 2, 'length should equal 2'); | ||
equal(tr.start(), 0, 'works if start is called with no arguments'); | ||
equal(tr.end(), 10, 'works if end is called with no arguments'); | ||
equal(tr.start(1), 11, 'works if start is called with valid index'); | ||
equal(tr.end(1), 20, 'works if end is called with with valid index'); | ||
assert.throws(()=>tr.start(-1), /Failed to execute 'start'/, 'fails if start is called with an invalid index'); | ||
assert.throws(()=>tr.end(-1), /Failed to execute 'end'/, 'fails if end is called with with an invalid index'); | ||
}); |