Google Groups

Re: [AngularJS] Re: Mock dep to test service error


Mike Spainhower Mar 19, 2013 3:14 PM
Posted in group: AngularJS
Thank you for posting this for others to find later, I forgot to come back and close this out :-)


On Tue, Mar 19, 2013 at 1:32 PM, Christian Dannie Storgaard <cyb...@gmail.com> wrote:
I believe the trick is to return null from the module ($provide) function - as it seems you've discovered as well ;)

So, for others stumbling on to this thread, this won't work:
module ($provide) ->
      $provide.value '$window', mock
      $provide.value '$q', q

this will:
module ($provide) ->
      $provide.value '$window', mock
      $provide.value '$q', q
      null

On Wednesday, 20 February 2013 13:00:16 UTC+2, Mike Spainhower wrote:
Is the documentation at http://docs.angularjs.org/guide/dev_guide.services.testing_services still valid?  I am trying to mock $window in the same fashion for a service's unit test, but get the following error when $provide.value('$window', mock) is present

Error: Argument 'fn' is not a function, got Object
            at assertArg (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:975)
            at assertArgFn (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:986)
            at annotate (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:2306)
            at invoke (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:2789)
            at /home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:2662


Thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/gCGF_B4eQkc/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.