From b029b70937a81f2b3404298fa62be0c14546839c Mon Sep 17 00:00:00 2001 From: Rajat Vig Date: Fri, 8 Jan 2016 10:30:38 -0800 Subject: [PATCH] Add expect clause when the test passes tests in q.extensions.spec.js are not asserting anything when the tests pass. This causes an error when running jasmine. Change-Id: I0589622944bdeaa69814181a431358b7c307219f Partial-Bug: #1532170 --- .../framework/util/q/q.extensions.spec.js | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/horizon/static/framework/util/q/q.extensions.spec.js b/horizon/static/framework/util/q/q.extensions.spec.js index 0f54ef2a6f..2d75118089 100644 --- a/horizon/static/framework/util/q/q.extensions.spec.js +++ b/horizon/static/framework/util/q/q.extensions.spec.js @@ -49,7 +49,7 @@ }, { promise: passedPromise(), context: '2' - }]).then(onAllSettled, failTest); + }]).then(onAllSettled); $scope.$apply(); @@ -76,28 +76,26 @@ }); it('should reject the promise if condition does not evaluates to true', function() { - service.booleanAsPromise(false).then(failTest, angular.noop); - $scope.$apply(); - service.booleanAsPromise(null).then(failTest, angular.noop); - $scope.$apply(); - service.booleanAsPromise({}).then(failTest, angular.noop); - $scope.$apply(); - service.booleanAsPromise('A').then(failTest, angular.noop); - $scope.$apply(); - service.booleanAsPromise(7).then(failTest, angular.noop); - $scope.$apply(); + var testValues = [ false, null, {}, 'A', 7 ]; + var rejectCount = 0; + testValues.map(function doTest(testValue) { + service.booleanAsPromise(testValue).then(angular.noop, function failTest() { + rejectCount++; + }); + $scope.$apply(); + }); + expect(rejectCount).toEqual(testValues.length); }); it('should resolve the promise only if condition to true', function() { - service.booleanAsPromise(true).then(angular.noop, failTest); + var passCount = 0; + service.booleanAsPromise(true).then(function passTest() { + passCount++; + }); $scope.$apply(); + expect(passCount).toEqual(1); }); - }); - - function failTest() { - expect(false).toBeTruthy(); - } }); })();