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
This commit is contained in:
Rajat Vig 2016-01-08 10:30:38 -08:00
parent 2b6f9525a8
commit b029b70937

View File

@ -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();
}
});
})();