-
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 Updates (DO NOT MERGE) #116
Conversation
@@ -1,2 +1,3 @@ | |||
/dist/ |
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.
do we have an npmignore? Because otherwise, npm would ignore the dist folder as well.
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.
Good point. Added an empty .npmignore file.
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.
Also, when this is ready to go, we should try publishing it to npm under a next or beta tag.
75e8d2f
to
3707f90
Compare
This can probably be reviewed, but should not be merged until we are sure it should be in |
Also, worth noting: two tests are currently broken in |
"qunitjs": "^1.17.1", | ||
"video.js": "^4.12.4" | ||
"sinon": "~1.16.1", |
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.
Nitpick but isn't ^
the best-practice version specifier these days?
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.
I thought it was ~
.
I've run into a lot of issues in the past with ^
bringing in breaking changes (despite semver saying minor versions should be backward-compatible); sometimes multiple dependency layers deep.
That said, I'm fine with changing these. It ought to be a company/project-wide standard, though.
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.
With sinon, I would even just get rid of the prefix altogether. They broke too many times on minor and patch releases to trust them.
lodash I think is fine to use ^
.
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.
Interesting. I've never had a problem with Sinon at all.
This was really tough to review. I know the timeout stuff was a pain to convert but it would have been a lot easier if we could have split the upgrade + refactor. |
Yeah, that's fair. There were so many test failures related to subtle differences in things that are now async that were not previously - as well as the order and structure of events between video.js and contrib-ads - that it would've been a big thing regardless. |
This is good for review once again. |
I'm using this PR for implementing ads in 5.0, but I have a suggestion: Could you add a Maybe this only makes sense after releasing? |
Would be nice to get @nickygerritsen's suggestions in here too but LGTM either way. |
player.ads = { | ||
state: 'content-set', | ||
|
||
// Call this when an ad response has been recieved and there are |
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.
Although not changed in this PR, recieved does not seem as a valid word to me ;). This is already wrong in the src
file of course.
The same typo is there 15 lines lower.
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.
You're right - "i" before "e" except after "c"! :)
- 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`.
de9e6bd
to
13b2bac
Compare
Closing in favor of #121 |
This updates the plugin for use with VideoJS 5.0 changes.
There is one functional change that should not affect consumers of the plugin whatsoever: there is no longer any use of
setImmediate
(non-standard) orrequestAnimationFrame
; rather, this is 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.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!