Merge "Add expect clause when the test passes"
This commit is contained in:
commit
d0b4c49f60
@ -49,7 +49,7 @@
|
|||||||
}, {
|
}, {
|
||||||
promise: passedPromise(),
|
promise: passedPromise(),
|
||||||
context: '2'
|
context: '2'
|
||||||
}]).then(onAllSettled, failTest);
|
}]).then(onAllSettled);
|
||||||
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
||||||
@ -76,28 +76,26 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reject the promise if condition does not evaluates to true', function() {
|
it('should reject the promise if condition does not evaluates to true', function() {
|
||||||
service.booleanAsPromise(false).then(failTest, angular.noop);
|
var testValues = [ false, null, {}, 'A', 7 ];
|
||||||
$scope.$apply();
|
var rejectCount = 0;
|
||||||
service.booleanAsPromise(null).then(failTest, angular.noop);
|
testValues.map(function doTest(testValue) {
|
||||||
$scope.$apply();
|
service.booleanAsPromise(testValue).then(angular.noop, function failTest() {
|
||||||
service.booleanAsPromise({}).then(failTest, angular.noop);
|
rejectCount++;
|
||||||
$scope.$apply();
|
});
|
||||||
service.booleanAsPromise('A').then(failTest, angular.noop);
|
$scope.$apply();
|
||||||
$scope.$apply();
|
});
|
||||||
service.booleanAsPromise(7).then(failTest, angular.noop);
|
expect(rejectCount).toEqual(testValues.length);
|
||||||
$scope.$apply();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve the promise only if condition to true', function() {
|
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();
|
$scope.$apply();
|
||||||
|
expect(passCount).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function failTest() {
|
|
||||||
expect(false).toBeTruthy();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user