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
Post a Comment