Can I inject a mock $window for a single directive but use the real $window in my test code?

62 views
Skip to first unread message

John Therrell

unread,
Feb 27, 2015, 4:18:38 PM2/27/15
to ang...@googlegroups.com
Hi Everyone,

I want to test a directive using a mock $window object so I can control the $window.location.protocol property which the directive inspects. However, my mock $window seems to also be used in my test code and my $compile calls in the test code and I can't create an element to test the directive.

Does angular provide a way for me to inject my mock $window only into my directive and allow me to use the real $window in other modules and test code?


Thanks,
John

John Therrell

unread,
Feb 27, 2015, 4:43:07 PM2/27/15
to ang...@googlegroups.com
Here's a working example of the issue: http://plnkr.co/edit/diIxwxc2D8BJo7cOzKmh?p=preview
Reply all
Reply to author
Forward
0 new messages