Skip to content

Commit

Permalink
fix: Fix tests for video.js 6 (#77)
Browse files Browse the repository at this point in the history
* update travis to test 5 & 6
* make queries local to errorDisplay rather than document
  • Loading branch information
brandonocasey authored Mar 9, 2017
1 parent b7ebfcd commit 0d71164
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ node_js:
- 'node'
- 'lts/argon'
before_script:
# check if the current version is equal to the version for the env
- 'export IS_INSTALLED="$(npm list video.js | grep "video.js@$VJS")"'
# we have to add semi colons to the end of each line in the if
# as travis runs this all on one line
- 'if [ -z "$IS_INSTALLED" ]; then
echo "INSTALLING video.js@>=$VJS.0.0-RC.0 <$(($VJS+1)).0.0";
npm i "video.js@>=$VJS.0.0-RC.0 <\$(($VJS+1)).0.0";
else
echo "video.js@$VJS ALREADY INSTALLED";
fi'
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
env:
- VJS=5
- VJS=6
addons:
firefox: latest
apt:
Expand Down
19 changes: 10 additions & 9 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ QUnit.module('videojs-errors', {

// initialize the plugin with the default options
this.player.errors();
this.errorDisplay = this.player.getChild('errorDisplay');

// Tick forward so the player is ready.
this.clock.tick(1);
Expand Down Expand Up @@ -376,9 +377,9 @@ QUnit.test('custom error details should override defaults', function(assert) {
// trigger the error in question
this.player.error(4);
// confirm results
assert.strictEqual(document.querySelector('.vjs-errors-headline').textContent,
assert.strictEqual(this.errorDisplay.$('.vjs-errors-headline').textContent,
customError.headline, 'headline should match custom override value');
assert.strictEqual(document.querySelector('.vjs-errors-message').textContent,
assert.strictEqual(this.errorDisplay.$('.vjs-errors-message').textContent,
customError.message, 'message should match custom override value');
});

Expand All @@ -401,7 +402,7 @@ QUnit.test('Append Flash error details when flash is not supported', function(as
// trigger the error in question
this.player.error(4);
// confirm results
assert.equal(document.querySelector('.vjs-errors-flashmessage').textContent,
assert.equal(this.errorDisplay.$('.vjs-errors-flashmessage').textContent,
' * If you are using an older browser please try upgrading or installing Flash.',
'Flash Error message should be displayed');
// Restoring isSupported to the old value
Expand All @@ -416,8 +417,8 @@ QUnit.test('default error is dismissible', function(assert) {
// trigger the error in question
this.player.error(2);
// confirm results
assert.ok(document.querySelector('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(document.querySelector('.vjs-close-button'), 'close button is present');
assert.ok(this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(this.errorDisplay.$('.vjs-close-button'), 'close button is present');
});

QUnit.test('custom error is dismissible', function(assert) {
Expand All @@ -434,8 +435,8 @@ QUnit.test('custom error is dismissible', function(assert) {
// trigger the error in question
this.player.error(4);
// confirm results
assert.ok(document.querySelector('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(document.querySelector('.vjs-close-button'), 'close button is present');
assert.ok(this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(this.errorDisplay.$('.vjs-close-button'), 'close button is present');
});

QUnit.test('custom error is not dismissible', function(assert) {
Expand All @@ -452,6 +453,6 @@ QUnit.test('custom error is not dismissible', function(assert) {
// trigger the error in question
this.player.error(4);
// confirm results
assert.ok(!document.querySelector('.vjs-errors-ok-button'), 'ok button is not present');
assert.ok(!document.querySelector('.vjs-close-button'), 'close button is not present');
assert.ok(!this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is not present');
assert.ok(!this.errorDisplay.$('.vjs-close-button'), 'close button is not present');
});

0 comments on commit 0d71164

Please sign in to comment.