0

I am using appstream embedded JavaScript file in my controller and getting appstream object from $window. But while mocking $window i don't have object for appstream bceause it is thirdparty content when iframe loaded.How can i write unit tests ?

In my controller i am accessing appstream object

var appstreamEmbed;
var _appStream = $window.AppStream;
Rajat
  • 398
  • 1
  • 5
  • 16
siri.p
  • 15
  • 5
  • You can just assign the AppStream object to $window object before calling your controller so that when controller is called AppStream object will be available the way it is required . – Rajat Apr 14 '20 at 18:37
  • I have tried to assign appstream object in before each. var window ={}; window.AppStream ={name : 'appstream'} but window.appstream is undefined – siri.p Apr 15 '20 at 06:41
  • You are creating the new object, so it will not work. You should assign it directly to $window object after you have injected in Unit test. Hope this helps. – Rajat Apr 16 '20 at 07:29

0 Answers0