@@ -7,11 +7,14 @@ import {
77import {
88 ActivatedRoute ,
99 Router ,
10+ UrlTree ,
1011} from '@angular/router' ;
1112import { RouterTestingModule } from '@angular/router/testing' ;
12- import { Observable } from 'rxjs' ;
1313
14- import { DAFF_AUTH_ROUTING_CONFIG } from '@daffodil/auth/routing' ;
14+ import {
15+ DAFF_AUTH_ROUTING_CONFIG ,
16+ provideDaffAuthRoutingConfig ,
17+ } from '@daffodil/auth/routing' ;
1518import { DaffResetPasswordLanding } from '@daffodil/auth/state' ;
1619import {
1720 DaffAuthStateTestingModule ,
@@ -34,10 +37,12 @@ describe('@daffodil/auth/routing | DaffAuthResetPasswordGuard', () => {
3437
3538 let param : string ;
3639 let token : string ;
40+ let redirectUrl : string ;
3741
3842 beforeEach ( ( ) => {
3943 param = 'token' ;
4044 token = '290384runfei9usnrg0ew9rgm' ;
45+ redirectUrl = 'redirectUrl' ;
4146
4247 TestBed . configureTestingModule ( {
4348 imports : [
@@ -60,6 +65,7 @@ describe('@daffodil/auth/routing | DaffAuthResetPasswordGuard', () => {
6065 resetPasswordTokenParam : param ,
6166 } ,
6267 } ,
68+ provideDaffAuthRoutingConfig ( { resetPasswordRedirectPath : redirectUrl } ) ,
6369 ] ,
6470 } ) ;
6571
@@ -71,7 +77,7 @@ describe('@daffodil/auth/routing | DaffAuthResetPasswordGuard', () => {
7177 } ) ;
7278
7379 describe ( 'canActivate | checking if the route can be activated' , ( ) => {
74- let result : Observable < boolean > ;
80+ let result : boolean | UrlTree ;
7581
7682 describe ( 'when there is a token set to the param' , ( ) => {
7783 beforeEach ( fakeAsync ( ( ) => {
@@ -80,15 +86,11 @@ describe('@daffodil/auth/routing | DaffAuthResetPasswordGuard', () => {
8086 result = guard . canActivate ( TestBed . inject ( ActivatedRoute ) . snapshot ) ;
8187 } ) ) ;
8288
83- it ( 'should allow activation' , done => {
84- result . subscribe ( res => {
85- expect ( res ) . toBeTrue ( ) ;
86- done ( ) ;
87- } ) ;
89+ it ( 'should allow activation' , ( ) => {
90+ expect ( result ) . toBeTrue ( ) ;
8891 } ) ;
8992
9093 it ( 'should dispatch DaffResetPasswordLanding with the token' , ( ) => {
91- result . subscribe ( ) ;
9294 expect ( mockFacade . dispatch ) . toHaveBeenCalledWith ( new DaffResetPasswordLanding ( token ) ) ;
9395 } ) ;
9496 } ) ;
@@ -100,15 +102,11 @@ describe('@daffodil/auth/routing | DaffAuthResetPasswordGuard', () => {
100102 result = guard . canActivate ( TestBed . inject ( ActivatedRoute ) . snapshot ) ;
101103 } ) ) ;
102104
103- it ( 'should not allow activation' , done => {
104- result . subscribe ( res => {
105- expect ( res ) . toBeFalse ( ) ;
106- done ( ) ;
107- } ) ;
105+ it ( 'should return the parsed redirect URL' , ( ) => {
106+ expect ( result . toString ( ) ) . toEqual ( `/${ redirectUrl } ` ) ;
108107 } ) ;
109108
110109 it ( 'should not dispatch DaffResetPasswordLanding with the token' , ( ) => {
111- result . subscribe ( ) ;
112110 expect ( mockFacade . dispatch ) . not . toHaveBeenCalledWith ( new DaffResetPasswordLanding ( token ) ) ;
113111 } ) ;
114112 } ) ;
0 commit comments