From e5c21c31599ef9307b3199164061cb7477c72ebd Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 14:34:03 +0100 Subject: [PATCH 01/22] Grunt JSHint job now runs against test files, and uses full rules as stated on the TAL GitHub pages coding standards --- .jshintrc | 57 ++++++++++++++++++++++++++++++++++++++++------------ gruntfile.js | 10 ++++++--- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/.jshintrc b/.jshintrc index 00d4b359..2524d507 100644 --- a/.jshintrc +++ b/.jshintrc @@ -20,20 +20,51 @@ "history": true, "unescape": true, "ActiveXObject": true, - "DOMParser": true + "DOMParser": true, + "sinon": true, + "assert": true, + "expectAsserts": true, + "assertEquals": true, + "queuedRequire": true, + "queuedApplicationInit": true, + "queuedComponentInit": true, + "assertClassName": true, + "assertSame": true, + "assertNotEquals": true, + "assertException": true, + "assertFalse": true, + "assertFunction": true, + "assertTrue": true, + "assertNull": true, + "assertInstanceOf": true, + "assertNoException": true, + "assertMatch": true, + "assertNotNull": true, + "assertNotSame": true, + "assertUndefined": true, + "assertBoolean": true, + "assertNotUndefined": true, + "assertNoMatch": true, + "assertObject": true, + "AsyncTestCase": true, + "jstestdriver": true, + "onDeviceTestConfigValidation": true, + "describe": true, + "beforeEach": true, + "it": true, + "expect": true }, - "asi": true, - "laxbreak": true, - "strict": true, + "browser": true, + "onevar": false, + "smarttabs": true, + "curly": true, + "eqeqeq": true, + "forin": true, + "immed": true, + "newcap": true, "noarg": true, - "validthis": true, - "latedef": "nofunc", + "nonew": true, + "plusplus": false, // Needs changing in docs "undef": true, - "funcscope": true, - "-W041": false, // Treble equals - "-W058": false, // Missing "()" invoking a constructor - "-W065": false, // Missing radix parameter - "boss": true, - "newcap": false, - "es3": true + "unused": true } \ No newline at end of file diff --git a/gruntfile.js b/gruntfile.js index 5adeccd9..5a1f3ab3 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -5,14 +5,18 @@ module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), jshint: { - files: ['static/script/**/*.js'], + files: ['static/script/**/*.js', + 'static/script-tests/**/*.js'], options: { jshintrc: '.jshintrc', + // options here to override JSHint defaults ignores: [ 'static/script/lib/*', 'static/script/devices/googletv.js', - 'static/script/devices/data/json2.js', - 'static/script/widgets/horizontalcarousel.js' + 'static/script-tests/api/jquery.js', + 'static/script-tests/lib/sinon.js', + 'static/script-tests/lib/require.js', + 'static/script/devices/data/json2.js' ] } }, From 527348120197c5a832a6d081320830890654a899 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 14:35:46 +0100 Subject: [PATCH 02/22] Removing unused Button in HorizontalCarousel test --- static/script-tests/tests/widgets/horizontalcarousel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/script-tests/tests/widgets/horizontalcarousel.js b/static/script-tests/tests/widgets/horizontalcarousel.js index 7ccaa71c..189bbee2 100644 --- a/static/script-tests/tests/widgets/horizontalcarousel.js +++ b/static/script-tests/tests/widgets/horizontalcarousel.js @@ -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(); From 9582f4885659adb347927b1a676c9c4bc0ba1cc9 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 14:43:00 +0100 Subject: [PATCH 03/22] Added missing hasOwnProperty check in navigator test helper --- .../widgets/carousel/navigators/testhelpers/navigator.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js b/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js index 1009df59..e35bafac 100644 --- a/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js +++ b/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js @@ -40,9 +40,11 @@ require.def('tests/widgets/navigators/testhelpers/navigator', var prototype, propertyName, property; prototype = Class.prototype; for (propertyName in prototype) { - property = prototype[propertyName]; - if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') { - self.sandbox.stub(prototype, propertyName); + if (prototype.hasOwnProperty(propertyName)) { + property = prototype[propertyName]; + if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') { + self.sandbox.stub(prototype, propertyName); + } } } } From f1e9e9c75cd56fce7b28b3228756215f8180fc46 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 15:00:06 +0100 Subject: [PATCH 04/22] Fixed JSHint errors in Carousel tests Ignored unused parameters where queueTest is passing them in anyway. Added missing hasOwnProperty check. --- static/script-tests/tests/widgets/carousel.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/static/script-tests/tests/widgets/carousel.js b/static/script-tests/tests/widgets/carousel.js index fdda1739..3d5830ca 100644 --- a/static/script-tests/tests/widgets/carousel.js +++ b/static/script-tests/tests/widgets/carousel.js @@ -56,9 +56,11 @@ var prototype, propertyName, property; prototype = Class.prototype; for (propertyName in prototype) { - property = prototype[propertyName]; - if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') { - self.sandbox.stub(prototype, propertyName); + if (prototype.hasOwnProperty(propertyName)) { + property = prototype[propertyName]; + if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') { + self.sandbox.stub(prototype, propertyName); + } } } } @@ -210,7 +212,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(); @@ -222,7 +224,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]); From a6dda2eab5f8858e6a80a0e7d171ac50526ff135 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:03:38 +0100 Subject: [PATCH 05/22] Renamed DoTest to doTest in Runtime Context tests --- static/script-tests/tests/runtimecontext.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/static/script-tests/tests/runtimecontext.js b/static/script-tests/tests/runtimecontext.js index b5d54330..917c4a80 100644 --- a/static/script-tests/tests/runtimecontext.js +++ b/static/script-tests/tests/runtimecontext.js @@ -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()); @@ -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({}); @@ -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()); @@ -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 () { @@ -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 From cf730668e4b1756a66c7a634a6108dd5a5eff530 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:07:20 +0100 Subject: [PATCH 06/22] Removing redundant test. Other tests would fail if creating a new Fornatter threw an exception. --- static/script-tests/tests/formatter.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/static/script-tests/tests/formatter.js b/static/script-tests/tests/formatter.js index c9964655..e134b396 100644 --- a/static/script-tests/tests/formatter.js +++ b/static/script-tests/tests/formatter.js @@ -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); From ff342db52243bea4105a656c0bb14838e2945f9d Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:42:19 +0100 Subject: [PATCH 07/22] Removing redundant test. Other tests would fail if creating a new MediaPlayer threw an exception. --- .../tests/devices/mediaplayer/mediaplayer.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/static/script-tests/tests/devices/mediaplayer/mediaplayer.js b/static/script-tests/tests/devices/mediaplayer/mediaplayer.js index 34fad395..aa9b48f1 100644 --- a/static/script-tests/tests/devices/mediaplayer/mediaplayer.js +++ b/static/script-tests/tests/devices/mediaplayer/mediaplayer.js @@ -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; From 9f56775d516973c282bcca242805f90f82debd87 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:47:39 +0100 Subject: [PATCH 08/22] Fixed JSHint errors in common media player tests Ignored unused parameters where doTest is passing them in anyway. Remove unused parameter. --- static/script-tests/tests/devices/mediaplayer/commontests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/script-tests/tests/devices/mediaplayer/commontests.js b/static/script-tests/tests/devices/mediaplayer/commontests.js index fe0f5cb8..ba609e05 100644 --- a/static/script-tests/tests/devices/mediaplayer/commontests.js +++ b/static/script-tests/tests/devices/mediaplayer/commontests.js @@ -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) { @@ -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 { From 1d9fc272d1dbaeece42a56d483bd498b55123c45 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:52:51 +0100 Subject: [PATCH 09/22] Fixed JSHint issues in Samsung media tests Removed unused queuedApplicaionInit dependencies. Removed unused variable. --- static/script-tests/tests/devices/media/samsung_maple.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/script-tests/tests/devices/media/samsung_maple.js b/static/script-tests/tests/devices/media/samsung_maple.js index 92054dab..be19e6cf 100644 --- a/static/script-tests/tests/devices/media/samsung_maple.js +++ b/static/script-tests/tests/devices/media/samsung_maple.js @@ -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); From e7ff147e004ae615ee09b3131c6352b7268f2271 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:54:52 +0100 Subject: [PATCH 10/22] Removing redundant test. Other tests would fail if creating a new MediaInterface threw an exception. --- .../script-tests/tests/devices/media/mediainterface.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/static/script-tests/tests/devices/media/mediainterface.js b/static/script-tests/tests/devices/media/mediainterface.js index dae6eedc..54a78320 100644 --- a/static/script-tests/tests/devices/media/mediainterface.js +++ b/static/script-tests/tests/devices/media/mediainterface.js @@ -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) { From e079fa0dcac56ce75e4d646eba4a57e6cf650239 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 18:56:43 +0100 Subject: [PATCH 11/22] Removed unused queuedApplicaionInit dependency. --- static/script-tests/tests/devices/media/html5.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/script-tests/tests/devices/media/html5.js b/static/script-tests/tests/devices/media/html5.js index 53ec4b68..c4de86ee 100644 --- a/static/script-tests/tests/devices/media/html5.js +++ b/static/script-tests/tests/devices/media/html5.js @@ -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(); From 1786d294b5dce60ed5f820b89727bf3491b0d84b Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 19:04:14 +0100 Subject: [PATCH 12/22] Reincluded commented out assertion. This was supposedly removed to enable on device testing, but removing the assertion would not help this. --- .../script-tests/tests/devices/exit/destroyapplication.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/script-tests/tests/devices/exit/destroyapplication.js b/static/script-tests/tests/devices/exit/destroyapplication.js index ecd29e0d..6d6a9e4f 100644 --- a/static/script-tests/tests/devices/exit/destroyapplication.js +++ b/static/script-tests/tests/devices/exit/destroyapplication.js @@ -39,7 +39,7 @@ * 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"}; @@ -47,11 +47,11 @@ 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; } }; From fccd52f85584bd318e14d3d726240ce9e3602156 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 19:10:56 +0100 Subject: [PATCH 13/22] Removed unused queuedApplicationInit dependencies --- static/script-tests/tests/devices/device.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/static/script-tests/tests/devices/device.js b/static/script-tests/tests/devices/device.js index f362fab4..d3e49cd5 100644 --- a/static/script-tests/tests/devices/device.js +++ b/static/script-tests/tests/devices/device.js @@ -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()); }); @@ -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(); @@ -102,7 +102,7 @@ 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() @@ -110,7 +110,6 @@ assertNoException(function() { Device.load(antie.framework.deviceConfiguration, callbacks); }); - var application = Application.getCurrentApplication(); var device = application.getDevice(); assertSame(antie.framework.deviceConfiguration, device.getConfig()); }); From 2b97956dc8215eccfd378f58fb8058a49229f9a6 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 19:14:53 +0100 Subject: [PATCH 14/22] Removed unused queuedApplicationInit dependencies --- .../tests/devices/broadcastsource/hbbtvsourcetest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/script-tests/tests/devices/broadcastsource/hbbtvsourcetest.js b/static/script-tests/tests/devices/broadcastsource/hbbtvsourcetest.js index f70929f1..bcb29fad 100644 --- a/static/script-tests/tests/devices/broadcastsource/hbbtvsourcetest.js +++ b/static/script-tests/tests/devices/broadcastsource/hbbtvsourcetest.js @@ -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(); From f1c669f82c15fcbab53011e75338f9e37eda597a Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 19:47:45 +0100 Subject: [PATCH 15/22] Removed unused variable --- static/script-tests/tests/devices/anim/styletopleft.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/static/script-tests/tests/devices/anim/styletopleft.js b/static/script-tests/tests/devices/anim/styletopleft.js index 662b7730..418c5d13 100644 --- a/static/script-tests/tests/devices/anim/styletopleft.js +++ b/static/script-tests/tests/devices/anim/styletopleft.js @@ -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 From 0783f26ad925a253d51da64c4f83caf63dfc8088 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 19:48:04 +0100 Subject: [PATCH 16/22] Added 'fail' to list of globals in .jshintrc --- .jshintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 2524d507..45136eef 100644 --- a/.jshintrc +++ b/.jshintrc @@ -52,7 +52,8 @@ "describe": true, "beforeEach": true, "it": true, - "expect": true + "expect": true, + "fail": true }, "browser": true, "onevar": false, From b5c653a2ac4aaff3275f89eceaed89873fce4e8c Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 19:58:29 +0100 Subject: [PATCH 17/22] Removed unused variable --- static/script-tests/tests/class.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/static/script-tests/tests/class.js b/static/script-tests/tests/class.js index 8b964b79..d3505024 100644 --- a/static/script-tests/tests/class.js +++ b/static/script-tests/tests/class.js @@ -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"; - } - }); }); }; @@ -140,4 +134,4 @@ }); }; -})(); +})(); From 4bda88cf3257886f288dbbaf475449c51033cc89 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 20:11:08 +0100 Subject: [PATCH 18/22] Removing unused parameter --- static/script-tests/lib/queuedrequire.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/script-tests/lib/queuedrequire.js b/static/script-tests/lib/queuedrequire.js index a38a40e6..73dcac61 100644 --- a/static/script-tests/lib/queuedrequire.js +++ b/static/script-tests/lib/queuedrequire.js @@ -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; From 56ab16383db9128be76145891d162b3e32f01f96 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Thu, 8 Oct 2015 20:17:52 +0100 Subject: [PATCH 19/22] Fixed JSHint errors in ondeviceconfigvalidate. Changed == to ===. Replaced 'var' keyword for global with 'window.'. --- static/script-tests/lib/ondevicetestconfigvalidate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/script-tests/lib/ondevicetestconfigvalidate.js b/static/script-tests/lib/ondevicetestconfigvalidate.js index c051867d..7e66b7f3 100644 --- a/static/script-tests/lib/ondevicetestconfigvalidate.js +++ b/static/script-tests/lib/ondevicetestconfigvalidate.js @@ -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 @@ -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 ){ From 784b55adc53b977d05129fef44c7775ec5e238ac Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Wed, 14 Oct 2015 15:25:58 +0100 Subject: [PATCH 20/22] Using .jshintrc from master --- .jshintrc | 58 +++++++++++++------------------------------------------ 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/.jshintrc b/.jshintrc index 45136eef..00d4b359 100644 --- a/.jshintrc +++ b/.jshintrc @@ -20,52 +20,20 @@ "history": true, "unescape": true, "ActiveXObject": true, - "DOMParser": true, - "sinon": true, - "assert": true, - "expectAsserts": true, - "assertEquals": true, - "queuedRequire": true, - "queuedApplicationInit": true, - "queuedComponentInit": true, - "assertClassName": true, - "assertSame": true, - "assertNotEquals": true, - "assertException": true, - "assertFalse": true, - "assertFunction": true, - "assertTrue": true, - "assertNull": true, - "assertInstanceOf": true, - "assertNoException": true, - "assertMatch": true, - "assertNotNull": true, - "assertNotSame": true, - "assertUndefined": true, - "assertBoolean": true, - "assertNotUndefined": true, - "assertNoMatch": true, - "assertObject": true, - "AsyncTestCase": true, - "jstestdriver": true, - "onDeviceTestConfigValidation": true, - "describe": true, - "beforeEach": true, - "it": true, - "expect": true, - "fail": true + "DOMParser": true }, - "browser": true, - "onevar": false, - "smarttabs": true, - "curly": true, - "eqeqeq": true, - "forin": true, - "immed": true, - "newcap": true, + "asi": true, + "laxbreak": true, + "strict": true, "noarg": true, - "nonew": true, - "plusplus": false, // Needs changing in docs + "validthis": true, + "latedef": "nofunc", "undef": true, - "unused": true + "funcscope": true, + "-W041": false, // Treble equals + "-W058": false, // Missing "()" invoking a constructor + "-W065": false, // Missing radix parameter + "boss": true, + "newcap": false, + "es3": true } \ No newline at end of file From a0708f5d41c186b9ab2ad1f91d781530d0a6bff3 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Wed, 14 Oct 2015 15:26:25 +0100 Subject: [PATCH 21/22] Using gruntfile.js from master --- gruntfile.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 5a1f3ab3..5adeccd9 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -5,18 +5,14 @@ module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), jshint: { - files: ['static/script/**/*.js', - 'static/script-tests/**/*.js'], + files: ['static/script/**/*.js'], options: { jshintrc: '.jshintrc', - // options here to override JSHint defaults ignores: [ 'static/script/lib/*', 'static/script/devices/googletv.js', - 'static/script-tests/api/jquery.js', - 'static/script-tests/lib/sinon.js', - 'static/script-tests/lib/require.js', - 'static/script/devices/data/json2.js' + 'static/script/devices/data/json2.js', + 'static/script/widgets/horizontalcarousel.js' ] } }, From 3c7a6f543e5a621209942e6c38f7882f736b63f4 Mon Sep 17 00:00:00 2001 From: tsadlerBBC Date: Wed, 14 Oct 2015 15:57:27 +0100 Subject: [PATCH 22/22] Removing hasOwnProperty check and adding jshint ignore:line where tests require inherited functions to be stubbed --- static/script-tests/tests/widgets/carousel.js | 10 ++++------ .../carousel/navigators/testhelpers/navigator.js | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/static/script-tests/tests/widgets/carousel.js b/static/script-tests/tests/widgets/carousel.js index 3d5830ca..d6a2867a 100644 --- a/static/script-tests/tests/widgets/carousel.js +++ b/static/script-tests/tests/widgets/carousel.js @@ -55,12 +55,10 @@ function stubUnstubbedFunctions(Class) { var prototype, propertyName, property; prototype = Class.prototype; - for (propertyName in prototype) { - if (prototype.hasOwnProperty(propertyName)) { - property = prototype[propertyName]; - if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') { - self.sandbox.stub(prototype, propertyName); - } + 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); } } } diff --git a/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js b/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js index e35bafac..ffc67938 100644 --- a/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js +++ b/static/script-tests/tests/widgets/carousel/navigators/testhelpers/navigator.js @@ -39,12 +39,10 @@ require.def('tests/widgets/navigators/testhelpers/navigator', function stubUnstubbedFunctions(Class) { var prototype, propertyName, property; prototype = Class.prototype; - for (propertyName in prototype) { - if (prototype.hasOwnProperty(propertyName)) { - property = prototype[propertyName]; - if ((typeof property === 'function') && !(property.restore && property.restore.sinon) && propertyName !== 'self') { - self.sandbox.stub(prototype, propertyName); - } + 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); } } }