-
Notifications
You must be signed in to change notification settings - Fork 257
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
VideoJS 5.0 Compatibility #121
Merged
Merged
Conversation
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 removes the variable use of setImmediate/clearImmediate and RAF; replacing it with universal use of setTimeout. - Tests were not great because they did a lot of manual overriding of setTimeout and friends. They will now use Sinon's fake timers feature instead. - Updates tests to use QUnit 2.0 style, for future compatibility. Related to this, there is a general shift here away from relying on any global state (outside of helper functions) in tests as that makes them less atomic.
Also added a `hasClass` function to make it easier to test that.
Not sure why this one test needs async handling, but it appears to. The only way to make it not async is to trigger the 'play' event on the player's `tech_` object.
This also renames the obscure `timeout` in the plugin to the more meaningful `adTimeoutTimeout`.
misteroneill
force-pushed
the
vjs-5-upgrade
branch
from
November 23, 2015 19:04
98d763b
to
b67dce5
Compare
misteroneill
force-pushed
the
vjs-5-upgrade
branch
from
November 23, 2015 19:05
b67dce5
to
774c48a
Compare
misteroneill
changed the title
VideoJS 5.0 Compatibility - CAUTION!
VideoJS 5.0 Compatibility
Nov 23, 2015
misteroneill
added a commit
that referenced
this pull request
Nov 23, 2015
VideoJS 5.0 Compatibility
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This branch is for the VideoJS 5.0 compatible version of videojs-contrib-ads; merging this pull request to master will make master no longer compatible with VideoJS pre-5.0.
Functional Changes
There is no longer any use of
setImmediate
(non-standard) orrequestAnimationFrame
; rather, timers are simplified to usesetTimeout
universally. This not only makes code easier to reason about - no need to think about the minor differences in 3 separate APIs - but it makes testing using Sinon's fake timers more straight-forward.There are two minor naming changes:
player.ads.timeout
has been renamedplayer.ads.adTimeoutTimeout
.player.ads.resumeEndedTimeout
is now exposed.For the most part, the upgrade process (outside the VideoJS 5.0 upgrade) should be mostly transparent for this plugin.
Testing Changes
The bulk of the changes in this PR are related to testing; this seemed like a good opportunity for that work. There were significant sources of fragility in the tests previously and this sweeps the entire test suite with changes like:
Reduced reliance on globals
Each test should have whatever scaffolding it needs attached to
this
, imported from other sources, or hidden in a closure. Leaking globals is a good way to cause hard-to-debug issues.Eliminated duplicated code
Particularly in setup/teardown processes, there was a ton of repetition. This should now be minimized via
sharedModuleHooks
.Switched to QUnit 2.0-style tests
QUnit
.QUnit.module
should be passedbeforeEach
/afterEach
hooks instead of the deprecatedsetup
/teardown
.assert
object passed into each test (defined byQUnit.test
).Reduced assertion fragility
There was a lot of use of
QUnit.assert.equal
, which could potentially lead to bugs.QUnit.assert.strictEqual
is used now, for the same reason===
is preferred to==
.Used Sinon extensively
Fake timers were already in use in a few places, but this makes that universal (particularly in the Flash tests). All custom/manual function spying is replaced by uses of
sinon.spy
- no more manual counting orpush
ing onto arrays!