I am trying to learn to write jasmine test cases to check whether the angular's modal popup is displayed when the page is loaded. So here how do I check whether the popup in angular is displayed on the page load or it is not getting displayed on the page? is this possible in unit testing?
Here is my sample code for modal popup, but in the following code modal popup is displayed only when the user clicks the button sample modal popup! and I also want to check whether the modal popup is displayed when the web app is loaded , but unfortunately I don't have the code which shows the popup on the page load.
angular.module('modal popup', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.open = function () {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
items: function () {
return $scope.items;
}
}
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
};
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function () {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
Can anyone here please help me in writing jasmine test cases to test whether the modal popup is displayed?
Varun Krishna. P