{"action":"created","issue":{"url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1695","labels_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1695/labels{/name}","comments_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1695/comments","events_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1695/events","html_url":"https://github.com/mgcrea/angular-strap/issues/1695","id":77669370,"number":1695,"title":"How to $modal (angular-strap) unit test? ","user":{"login":"winiciuswanderlei","id":7283144,"avatar_url":"https://avatars.githubusercontent.com/u/7283144?v=3","gravatar_id":"","url":"https://api.github.com/users/winiciuswanderlei","html_url":"https://github.com/winiciuswanderlei","followers_url":"https://api.github.com/users/winiciuswanderlei/followers","following_url":"https://api.github.com/users/winiciuswanderlei/following{/other_user}","gists_url":"https://api.github.com/users/winiciuswanderlei/gists{/gist_id}","starred_url":"https://api.github.com/users/winiciuswanderlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winiciuswanderlei/subscriptions","organizations_url":"https://api.github.com/users/winiciuswanderlei/orgs","repos_url":"https://api.github.com/users/winiciuswanderlei/repos","events_url":"https://api.github.com/users/winiciuswanderlei/events{/privacy}","received_events_url":"https://api.github.com/users/winiciuswanderlei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-18T14:07:38Z","updated_at":"2015-05-19T16:53:26Z","closed_at":null,"body":"In my unit test when I call the function that has called the modal get the following error:\r\nTypeError: Cannot read property '$promise' of undefined\r\n\r\nIn the controller I have:\r\n$scope.showModal = function(){\r\n  $scope.addModal = $modal({ scope: $scope, template: 'form.tpl.html', show: false });\r\n  $scope.addModal.$promise.then($scope.addModal.show);\r\n}\r\n\r\nIn my test I have:\r\nit('Show modal', function(){\r\n      Controller.showModal();\r\n});"},"comment":{"url":"https://api.github.com/repos/mgcrea/angular-strap/issues/comments/103589563","html_url":"https://github.com/mgcrea/angular-strap/issues/1695#issuecomment-103589563","issue_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1695","id":103589563,"user":{"login":"vmlf01","id":4786750,"avatar_url":"https://avatars.githubusercontent.com/u/4786750?v=3","gravatar_id":"","url":"https://api.github.com/users/vmlf01","html_url":"https://github.com/vmlf01","followers_url":"https://api.github.com/users/vmlf01/followers","following_url":"https://api.github.com/users/vmlf01/following{/other_user}","gists_url":"https://api.github.com/users/vmlf01/gists{/gist_id}","starred_url":"https://api.github.com/users/vmlf01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmlf01/subscriptions","organizations_url":"https://api.github.com/users/vmlf01/orgs","repos_url":"https://api.github.com/users/vmlf01/repos","events_url":"https://api.github.com/users/vmlf01/events{/privacy}","received_events_url":"https://api.github.com/users/vmlf01/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T16:53:26Z","updated_at":"2015-05-19T16:53:26Z","body":"On the modal tests spec, there is a test for using the $modal service, which is very similar to what you are doing, except that the call to show is not done right after the creation of the modal:\r\nhttps://github.com/mgcrea/angular-strap/blob/master/src/modal/test/modal.spec.js#L152\r\n\r\nNot sure why your test is failing."}}