-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vjsstandard - Tests - Utils folder #3482
Merged
misteroneill
merged 2 commits into
videojs:vjsstandard-core
from
brandonocasey:chore/test-linting-pt3
Aug 3, 2016
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,13 +1,14 @@ | ||
/* eslint-env qunit */ | ||
import * as Fn from '../../../src/js/utils/fn.js'; | ||
|
||
q.module('fn'); | ||
QUnit.module('fn'); | ||
|
||
test('should add context to a function', function(){ | ||
var newContext = { test: 'obj'}; | ||
var asdf = function(){ | ||
ok(this === newContext); | ||
QUnit.test('should add context to a function', function() { | ||
const newContext = { test: 'obj'}; | ||
const asdf = function() { | ||
QUnit.ok(this === newContext); | ||
}; | ||
var fdsa = Fn.bind(newContext, asdf); | ||
const fdsa = Fn.bind(newContext, asdf); | ||
|
||
fdsa(); | ||
}); |
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,35 +1,35 @@ | ||
/* eslint-env qunit */ | ||
import formatTime from '../../../src/js/utils/format-time.js'; | ||
|
||
q.module('format-time'); | ||
QUnit.module('format-time'); | ||
|
||
test('should format time as a string', function(){ | ||
ok(formatTime(1) === '0:01'); | ||
ok(formatTime(10) === '0:10'); | ||
ok(formatTime(60) === '1:00'); | ||
ok(formatTime(600) === '10:00'); | ||
ok(formatTime(3600) === '1:00:00'); | ||
ok(formatTime(36000) === '10:00:00'); | ||
ok(formatTime(360000) === '100:00:00'); | ||
QUnit.test('should format time as a string', function() { | ||
QUnit.ok(formatTime(1) === '0:01'); | ||
QUnit.ok(formatTime(10) === '0:10'); | ||
QUnit.ok(formatTime(60) === '1:00'); | ||
QUnit.ok(formatTime(600) === '10:00'); | ||
QUnit.ok(formatTime(3600) === '1:00:00'); | ||
QUnit.ok(formatTime(36000) === '10:00:00'); | ||
QUnit.ok(formatTime(360000) === '100:00:00'); | ||
|
||
// Using guide should provide extra leading zeros | ||
ok(formatTime(1,1) === '0:01'); | ||
ok(formatTime(1,10) === '0:01'); | ||
ok(formatTime(1,60) === '0:01'); | ||
ok(formatTime(1,600) === '00:01'); | ||
ok(formatTime(1,3600) === '0:00:01'); | ||
QUnit.ok(formatTime(1, 1) === '0:01'); | ||
QUnit.ok(formatTime(1, 10) === '0:01'); | ||
QUnit.ok(formatTime(1, 60) === '0:01'); | ||
QUnit.ok(formatTime(1, 600) === '00:01'); | ||
QUnit.ok(formatTime(1, 3600) === '0:00:01'); | ||
// Don't do extra leading zeros for hours | ||
ok(formatTime(1,36000) === '0:00:01'); | ||
ok(formatTime(1,360000) === '0:00:01'); | ||
QUnit.ok(formatTime(1, 36000) === '0:00:01'); | ||
QUnit.ok(formatTime(1, 360000) === '0:00:01'); | ||
|
||
// Do not display negative time | ||
ok(formatTime(-1) === '0:00'); | ||
ok(formatTime(-1,3600) === '0:00:00'); | ||
QUnit.ok(formatTime(-1) === '0:00'); | ||
QUnit.ok(formatTime(-1, 3600) === '0:00:00'); | ||
}); | ||
|
||
test('should format invalid times as dashes', function(){ | ||
equal(formatTime(Infinity, 90), '-:-'); | ||
equal(formatTime(NaN), '-:-'); | ||
// equal(formatTime(NaN, 216000), '-:--:--'); | ||
equal(formatTime(10, Infinity), '0:00:10'); | ||
equal(formatTime(90, NaN), '1:30'); | ||
QUnit.test('should format invalid times as dashes', function() { | ||
QUnit.equal(formatTime(Infinity, 90), '-:-'); | ||
QUnit.equal(formatTime(NaN), '-:-'); | ||
QUnit.equal(formatTime(10, Infinity), '0:00:10'); | ||
QUnit.equal(formatTime(90, NaN), '1:30'); | ||
}); |
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,30 +1,45 @@ | ||
/* eslint-env qunit */ | ||
import { createTimeRanges, createTimeRange } from '../../../src/js/utils/time-ranges.js'; | ||
|
||
q.module('time-ranges'); | ||
QUnit.module('time-ranges'); | ||
|
||
test('should export the deprecated createTimeRange function', function(){ | ||
equal(createTimeRange, createTimeRanges, 'createTimeRange is an alias to createTimeRanges'); | ||
QUnit.test('should export the deprecated createTimeRange function', function() { | ||
QUnit.equal(createTimeRange, | ||
createTimeRanges, | ||
'createTimeRange is an alias to createTimeRanges'); | ||
}); | ||
|
||
test('should create a fake single timerange', function(assert){ | ||
var tr = createTimeRanges(0, 10); | ||
QUnit.test('should create a fake single timerange', function(assert) { | ||
const tr = createTimeRanges(0, 10); | ||
|
||
equal(tr.length, 1, 'length should be 1'); | ||
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'); | ||
QUnit.equal(tr.length, 1, 'length should be 1'); | ||
QUnit.equal(tr.start(0), | ||
0, | ||
'works if start is called with valid index'); | ||
QUnit.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([ | ||
QUnit.test('should create a fake multiple timerange', function(assert) { | ||
const tr = createTimeRanges([ | ||
[0, 10], | ||
[11, 20] | ||
]); | ||
|
||
equal(tr.length, 2, 'length should equal 2'); | ||
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'); | ||
QUnit.equal(tr.length, 2, 'length should equal 2'); | ||
QUnit.equal(tr.start(1), 11, 'works if start is called with valid index'); | ||
QUnit.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'); | ||
}); |
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,8 +1,10 @@ | ||
/* eslint-env qunit */ | ||
import toTitleCase from '../../../src/js/utils/to-title-case.js'; | ||
|
||
q.module('to-title-case'); | ||
QUnit.module('to-title-case'); | ||
|
||
test('should make a string start with an uppercase letter', function(){ | ||
var foo = toTitleCase('bar'); | ||
ok(foo === 'Bar'); | ||
QUnit.test('should make a string start with an uppercase letter', function() { | ||
const foo = toTitleCase('bar'); | ||
|
||
QUnit.ok(foo === 'Bar'); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are great function names...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha