Skip to content
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

Throw an error if techOrder isn't in options. For #1998 #2097

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,21 @@ module.exports = function(grunt) {
}
},
browserify: {
options: {
transform: [
require('babelify').configure({
sourceMapRelative: './src/js'
}),
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
}],
['browserify-versionify', {
placeholder: '__VERSION_NO_PATCH__',
version: version.majorMinor
}]
]
},
build: {
files: {
'build/temp/video.js': ['src/js/video.js']
Expand All @@ -275,19 +290,15 @@ module.exports = function(grunt) {
banner: license,
plugin: [
[ 'browserify-derequire' ]
],
transform: [
require('babelify').configure({
sourceMapRelative: './src/js'
}),
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
}],
['browserify-versionify', {
placeholder: '__VERSION_NO_PATCH__',
version: version.majorMinor
}]
]
}
},
test: {
files: {
'build/temp/tests.js': [
'test/globals-shim.js',
'test/unit/**/*.js',
'test/api/**.js'
]
}
}
Expand All @@ -301,6 +312,9 @@ module.exports = function(grunt) {
}
},
coveralls: {
options: {
force: true
},
all: {
src: 'test/coverage/lcov.info'
}
Expand Down
11 changes: 11 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ class Player extends Component {
// Run base component initializing with new options
super(null, options, ready);


// if the global option object was accidentally blown away by
// someone, bail early with an informative error
if (!this.options_ ||
!this.options_.techOrder ||
!this.options_.techOrder.length) {
throw new Error('No techOrder specified. Did you overwrite ' +
'videojs.options instead of just changing the ' +
'properties you want to override?');
}

this.tag = tag; // Store the original tag used to set options

// Store the tag attributes used to restore html5 element
Expand Down
10 changes: 10 additions & 0 deletions test/globals-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import window from 'global/window';
import sinon from 'sinon';

window.q = QUnit;
window.sinon = sinon;

// This may not be needed anymore, but double check before removing
window.fixture = document.createElement('div');
fixture.id = 'qunit-fixture';
document.body.appendChild(fixture);
15 changes: 15 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>VideoJS Tests</title>
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
<link rel="stylesheet" href="../build/temp/video-js.min.css">
</head>
<body>
<div id="qunit"></div>
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../build/temp/tests.js"></script>
<script src="api/api.js"></script>
</body>
</html>
6 changes: 0 additions & 6 deletions test/karma-qunit-shim.js

This file was deleted.

9 changes: 2 additions & 7 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,16 @@ module.exports = function(config) {
config.set({
basePath: '',

frameworks: ['browserify', 'qunit', 'sinon'],
frameworks: ['browserify', 'qunit'],

autoWatch: false,

singleRun: true,

// customLaunchers: customLaunchers,

files: [
'../build/temp/video-js.min.css',
'../test/karma-qunit-shim.js',
'../test/unit/**/*.js',
'../build/temp/video.min.js',
'../test/api/**/*.js',
'../build/temp/tests.js',
],

preprocessors: {
Expand All @@ -84,7 +80,6 @@ module.exports = function(config) {
'karma-phantomjs-launcher',
'karma-safari-launcher',
'karma-sauce-launcher',
'karma-sinon',
'karma-browserify',
'karma-coverage'
],
Expand Down
11 changes: 11 additions & 0 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,14 @@ test('should be scrubbing while seeking', function(){
equal(player.scrubbing(), true, 'player is scrubbing');
ok(player.el().className.indexOf('scrubbing') !== -1, 'scrubbing class is present');
});

test('should throw on startup no techs are specified', function() {
const techOrder = Options.techOrder;

Options.techOrder = null;
q.throws(function() {
videojs(TestHelpers.makeTag());
}, 'a falsey techOrder should throw');

Options.techOrder = techOrder;
});