Skip to content

Commit

Permalink
Merge pull request #296 from fmtvp/jshint-merge
Browse files Browse the repository at this point in the history
WIP JSHint fixes
  • Loading branch information
rthompson1991 committed Oct 14, 2015
2 parents 7642781 + 3c7a6f5 commit d61b4b8
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 68 deletions.
4 changes: 2 additions & 2 deletions static/script-tests/lib/ondevicetestconfigvalidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Return (Bool) True if test can be run on this device, otherwise false
*/

var onDeviceTestConfigValidation = {
window.onDeviceTestConfigValidation = {
removeTestsForIncompatibleDevices : function( modifiers, testObject ){

//this indicates we are testing on a device and want to exclude tests based on configs
Expand All @@ -13,7 +13,7 @@ var onDeviceTestConfigValidation = {

for( var m0 in modifiers ){
//look for each modifier in the actual device configuration
if( window.deviceConfig.modules.modifiers.indexOf( modifiers[ m0 ] ) == -1 ){
if( window.deviceConfig.modules.modifiers.indexOf( modifiers[ m0 ] ) === -1 ){
//if a modifier is not found then this is not a valid test
for( var tr in testObject.prototype ){
if( tr.indexOf( "test" ) === 0 ){
Expand Down
2 changes: 1 addition & 1 deletion static/script-tests/lib/queuedrequire.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function __qr(){
requireModules[name] = arguments;
originalRequireDefine.apply(require, arguments);
};
require.load = function(moduleName, contextName) {
require.load = function(moduleName) {
var module = requireModules[moduleName];
if(module) {
require.s.contexts._.specified[moduleName] = true;
Expand Down
8 changes: 1 addition & 7 deletions static/script-tests/tests/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@

assertEquals("Example method returns expected value", "method", obj.returnMethodString());
assertEquals("Constructor sets expected value", "value", obj._variable);

var ExtendedTwiceClass = ExtendedClass.extend({
overridableFunction: function() {
return "subclass";
}
});
});
};

Expand Down Expand Up @@ -140,4 +134,4 @@
});
};

})();
})();
3 changes: 0 additions & 3 deletions static/script-tests/tests/devices/anim/styletopleft.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
*/

(function() {
// How many milliseconds to give a 'no animation' transition to complete
var noAnimToleranceMs = 20;

// The default animation duration in tween.js is 840, so it's reasonable to think we should only need to tick for
// 840 to get the onComplete callback to be fired. However the callback passed to shifty that invokes onComplete
// doesn't run until tick 866.666666666667. This seems to be because the Shifty timeoutHandler waits for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@

var self = this;
var config = getGenericHBBTVConfig();
queuedApplicationInit(queue, 'lib/mockapplication', ['antie/events/tunerpresentingevent'], function(application, TunerPresentingEvent) {
queuedApplicationInit(queue, 'lib/mockapplication', [], function(application) {

var device = application.getDevice();
device.createBroadcastSource();
Expand Down
11 changes: 5 additions & 6 deletions static/script-tests/tests/devices/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
queuedApplicationInit(
queue,
"lib/mockapplication",
["antie/devices/device","antie/class"],
function(application, Device, Class) {
["antie/devices/device"],
function(application, Device) {
var device = new Device(antie.framework.deviceConfiguration);
assertFalse(device.isBroadcastSourceSupported());
});
Expand All @@ -66,8 +66,8 @@
queuedApplicationInit(
queue,
"lib/mockapplication",
["antie/devices/device","antie/class"],
function(application, Device, Class) {
["antie/devices/device"],
function(application, Device) {
var device = new Device(antie.framework.deviceConfiguration);
assertException("Broadcast API not available on this device.", function() {
device.createBroadcastSource();
Expand Down Expand Up @@ -102,15 +102,14 @@
this.DeviceTest.prototype.testGetConfig = function(queue) {
expectAsserts(2);

queuedApplicationInit(queue, "lib/mockapplication", ["antie/devices/device","antie/application"], function(application, Device, Application) {
queuedApplicationInit(queue, "lib/mockapplication", ["antie/devices/device"], function(application, Device) {
var callbacks = {
onSuccess: this.sandbox.stub(),
onError: this.sandbox.stub()
};
assertNoException(function() {
Device.load(antie.framework.deviceConfiguration, callbacks);
});
var application = Application.getCurrentApplication();
var device = application.getDevice();
assertSame(antie.framework.deviceConfiguration, device.getConfig());
});
Expand Down
6 changes: 3 additions & 3 deletions static/script-tests/tests/devices/exit/destroyapplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@
* requesting the correct MIME type for the HBBTV application manager.
*/
this.DestroyApplicationTest.prototype.testGetOipfObjectFactory = function(queue) {
expectAsserts(1);
expectAsserts(2);

var config = {"modules":{"base":"antie/devices/browserdevice","modifiers":["antie/devices/exit/destroyapplication"]},"input":{"map":{}},"layouts":[{"width":960,"height":540,"module":"fixtures/layouts/default","classes":["browserdevice540p"]}],"deviceConfigurationKey":"devices-html5-1"};

var self = this;

queuedApplicationInit(queue, "lib/mockapplication", [], function(application) {
var expectedMimeType = 'application/oipfApplicationManager';

// Mimic the object provided by HBBTVs
window.oipfObjectFactory = {
isObjectSupported: function(mimeType) {
//assertEquals('Requested MIME type is as expected', expectedMimeType, mimeType);
assertEquals('Requested MIME type is as expected', expectedMimeType, mimeType);
return false;
}
};
Expand Down
4 changes: 2 additions & 2 deletions static/script-tests/tests/devices/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
this.HTML5Test.prototype.testRenderCausesPlayEventListenerCallbackWithAPlayMediaEvent = function (queue) {
expectAsserts(4);
var self = this;
queuedApplicationInit(queue, 'lib/mockapplication', ["antie/devices/media/html5", "antie/events/mediaevent", "antie/devices/media/mediainterface"],
function(application, HTML5Player, MediaEvent, MediaInterface) {
queuedApplicationInit(queue, 'lib/mockapplication', ["antie/devices/media/html5", "antie/events/mediaevent"],
function(application, HTML5Player, MediaEvent) {

var callbackStub = self.sandbox.stub();

Expand Down
9 changes: 0 additions & 9 deletions static/script-tests/tests/devices/media/mediainterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
this.sandbox.restore();
};

this.MediaInterfaceTest.prototype.testMediaInterfaceInitDoesNotThrowAnExceptionWhenCalled = function (queue) {
expectAsserts(1);
queuedApplicationInit(queue, 'lib/mockapplication', ["antie/devices/media/mediainterface"], function(application, MediaInterface) {
assertNoException(function() {
new MediaInterface('id', 'video', function(){});
});
});
};

this.MediaInterfaceTest.prototype.testMediaInterfaceRenderDoesNotThrowAnExceptionWhenCalled = function (queue) {
expectAsserts(1);
queuedApplicationInit(queue, 'lib/mockapplication', ["antie/devices/media/mediainterface"], function(application, MediaInterface) {
Expand Down
6 changes: 3 additions & 3 deletions static/script-tests/tests/devices/media/samsung_maple.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@
this.SamsungMapleTest.prototype.testThatStopIsCalledOnThePlayerPluginWhenAHideEventIsFired = function (queue) {
expectAsserts(1);
var self = this;
queuedApplicationInit(queue, 'lib/mockapplication', ["antie/devices/media/samsung_maple", "antie/events/mediaevent"],
function(application, SamsungPlayer, MediaErrorEvent) {
queuedApplicationInit(queue, 'lib/mockapplication', [],
function(application) {

var callbackStub = self.sandbox.stub();
var mediaInterface = application.getDevice().createMediaInterface("id", "video", callbackStub);
application.getDevice().createMediaInterface("id", "video", callbackStub);

var event = new CustomEvent('hide');
window.dispatchEvent(event);
Expand Down
4 changes: 2 additions & 2 deletions static/script-tests/tests/devices/mediaplayer/commontests.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ window.commonTests.mediaPlayer.all.mixinTests = function (testCase, mediaPlayerD
return test;
};

var makeDeviceErrorGetsReported = function (setup, deviceEventName) {
var makeDeviceErrorGetsReported = function (setup) {
var test = function (queue) {
expectAsserts(4);
doTest(this, queue, function (MediaPlayer) {
Expand Down Expand Up @@ -897,7 +897,7 @@ window.commonTests.mediaPlayer.all.mixinTests = function (testCase, mediaPlayerD
var makeStandardErrorWhileMakingCallInEmptyAndErrorStatesIsLoggedTest = function(method, args) {
return function(queue) {
expectAsserts(2);
doTest(this, queue, function (MediaPlayer) {
doTest(this, queue, function (MediaPlayer) { //jshint ignore:line
var errorStub = this.sandbox.stub();
this.sandbox.stub(this.device, "getLogger").returns({error: errorStub});
try {
Expand Down
9 changes: 0 additions & 9 deletions static/script-tests/tests/devices/mediaplayer/mediaplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
this.sandbox.restore();
};

this.MediaPlayerTest.prototype.testMediaPlayerInitDoesNotThrowAnExceptionWhenCalled = function (queue) {
expectAsserts(1);
queuedRequire(queue, ["antie/devices/mediaplayer/mediaplayer"], function(MediaPlayer) {
assertNoException(function() {
new MediaPlayer();
});
});
};

var createSubClass = function(MediaPlayer) {
var range = { start: 0, end: 100 };
var currentTime = 0;
Expand Down
8 changes: 0 additions & 8 deletions static/script-tests/tests/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
});
};

this.FormatterTest.prototype.testConstructorAcceptsEmptyArguments = function(queue) {
expectAsserts(1);

queuedRequire(queue, ["antie/formatter"], function(Formatter) {
assertNoException(function() { new Formatter(); });
});
};

this.FormatterTest.prototype.testNonOverriddenFormatThrowsException = function(queue) {
expectAsserts(1);

Expand Down
12 changes: 6 additions & 6 deletions static/script-tests/tests/runtimecontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

this.RuntimeContextTest.prototype.testGetApplicationWhenNoApplicationIsSet = function(queue) {
expectAsserts(1);
DoTest(queue, function(RuntimeContext) {
doTest(queue, function(RuntimeContext) {
assertEquals(undefined, RuntimeContext.getCurrentApplication());
});
};

this.RuntimeContextTest.prototype.testSetApplication = function(queue) {
expectAsserts(1);
DoTest(queue, function(RuntimeContext) {
doTest(queue, function(RuntimeContext) {
var mockApplication = {};
RuntimeContext.setCurrentApplication(mockApplication);
assertEquals(mockApplication, RuntimeContext.getCurrentApplication());
Expand All @@ -43,7 +43,7 @@

this.RuntimeContextTest.prototype.testSetApplicationTwiceCausesError = function(queue) {
expectAsserts(1);
DoTest(queue, function(RuntimeContext) {
doTest(queue, function(RuntimeContext) {
RuntimeContext.setCurrentApplication({});
assertException(function () {
RuntimeContext.setCurrentApplication({});
Expand All @@ -54,7 +54,7 @@

this.RuntimeContextTest.prototype.testClearApplication = function(queue) {
expectAsserts(1);
DoTest(queue, function(RuntimeContext) {
doTest(queue, function(RuntimeContext) {
RuntimeContext.setCurrentApplication({});
RuntimeContext.clearCurrentApplication();
assertEquals(undefined, RuntimeContext.getCurrentApplication());
Expand All @@ -63,7 +63,7 @@

this.RuntimeContextTest.prototype.testGetDevice = function(queue) {
expectAsserts(1);
DoTest(queue, function(RuntimeContext) {
doTest(queue, function(RuntimeContext) {
var mockDevice = {};
var mockApplication = {
getDevice: function () {
Expand All @@ -76,7 +76,7 @@
};

// Helper
function DoTest (queue, test) {
function doTest (queue, test) {
queuedRequire(queue, ["antie/runtimecontext"], function(RuntimeContext) { // Make sure the class under test is available
var original = RuntimeContext.getCurrentApplication();
RuntimeContext.clearCurrentApplication(); // Start from scratch each time
Expand Down
6 changes: 3 additions & 3 deletions static/script-tests/tests/widgets/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
function stubUnstubbedFunctions(Class) {
var prototype, propertyName, property;
prototype = Class.prototype;
for (propertyName in prototype) {
for (propertyName in prototype) { //jshint ignore:line
property = prototype[propertyName];
if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') {
self.sandbox.stub(prototype, propertyName);
Expand Down Expand Up @@ -210,7 +210,7 @@

this.CarouselTest.prototype.testGetChildWidgetWithMaskIdCallsCore = function (queue) {
var self = this;
function testFunction(application, Carousel, WidgetStrip, Mask, Navigator, Button, Container, CarouselCore) {
function testFunction(application, Carousel, WidgetStrip, Mask, Navigator, Button, Container, CarouselCore) { //jshint ignore:line
var carousel, widget;
stubClassPrototypes(self, [WidgetStrip, Mask, Button, Navigator, Container]);
carousel = new Carousel();
Expand All @@ -222,7 +222,7 @@

this.CarouselTest.prototype.testGetChildWidgetWithNonMaskIdCallsWidgetStrip = function (queue) {
var self = this;
function testFunction(application, Carousel, WidgetStrip, Mask, Navigator, Button, Container, CarouselCore) {
function testFunction(application, Carousel, WidgetStrip, Mask, Navigator, Button, Container, CarouselCore) { //jshint ignore:line
var carousel;
self.sandbox.stub(WidgetStrip.prototype, 'getChildWidget');
stubClassPrototypes(self, [WidgetStrip, Mask, Button, Navigator, Container]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require.def('tests/widgets/navigators/testhelpers/navigator',
function stubUnstubbedFunctions(Class) {
var prototype, propertyName, property;
prototype = Class.prototype;
for (propertyName in prototype) {
for (propertyName in prototype) { //jshint ignore:line
property = prototype[propertyName];
if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') {
self.sandbox.stub(prototype, propertyName);
Expand Down
4 changes: 2 additions & 2 deletions static/script-tests/tests/widgets/horizontalcarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@
queuedApplicationInit(
queue,
"lib/mockapplication",
["antie/widgets/horizontalcarousel", "antie/widgets/list", "antie/widgets/button"],
function(application, HorizontalCarousel, List, Button) {
["antie/widgets/horizontalcarousel", "antie/widgets/list"],
function(application, HorizontalCarousel, List) {
var widget = new HorizontalCarousel("id");
widget.setRenderMode(List.RENDER_MODE_CONTAINER);
var device = application.getDevice();
Expand Down

0 comments on commit d61b4b8

Please sign in to comment.