javascript - how can i create MockActivatedRoute for the parent routes of ActivatedRoute in angular 4 Unit testing -


lets have component access parent route this:

ngoninit() {     this.sub = this.route.parent.parent.parent.params.subscribe(params => {     this.siteid = params["siteid"];     this.loadcontents();     this.loadtypes(this.siteid); });} 

i m providing fake value parent route this:

 providers: [         siteservice,         userservice,         modal,         overlay,         {             provide: activatedroute,             usevalue: { parent: { parent: { parent: { 'params': observable.from([{ 'siteid': '156' }]) } } } },         },         overlayrenderer,         authhttp,         messageservice,     ], 

it giving me following error:

failed: cannot read property 'undefined' of undefined

at line:

usevalue: { parent: { parent: { parent: { 'params': observable.from([{ 'siteid': '156' }]) } } } },

please tell me doing in correct. have referenced following link:

how mock activatedroute parent route, testing angular 2 parent route


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -