Skip to content

Commit 6847bc3

Browse files
committed
PD-3786 actually fix tests and guard
1 parent eb878bd commit 6847bc3

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/app/guards/reset-password.guard.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { ResetPasswordGuard } from './reset-password.guard'
99
import { RouterTestingModule } from '@angular/router/testing'
1010
const ApplicationRoutes = {
11-
signin: '',
11+
signin: 'signin',
1212
}
1313

1414
describe('ResetPasswordGuard', () => {
@@ -41,10 +41,9 @@ describe('ResetPasswordGuard', () => {
4141
const mockRoute = createMockRouteSnapshot('some-token-value')
4242
const result = guard.canActivate(mockRoute, mockStateSnapshot)
4343
expect(result).toBeTruthy()
44-
expect(result).toBe('some-token-value')
4544
})
4645

47-
it('should return a UrlTree to home if the "key" query parameter does not exist', () => {
46+
it('should return a UrlTree to signin if the "key" query parameter does not exist', () => {
4847
const mockRoute = createMockRouteSnapshot(null)
4948
const routerSpy = spyOn(router, 'createUrlTree').and.callThrough()
5049

src/app/guards/reset-password.guard.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export class ResetPasswordGuard {
2222
| Promise<boolean | UrlTree>
2323
| boolean
2424
| UrlTree {
25-
return (
26-
next.params['key'] ||
27-
this._router.createUrlTree([ApplicationRoutes.signin])
28-
)
25+
const key = next.params['key']
26+
return !!key || this._router.createUrlTree([ApplicationRoutes.signin])
2927
}
3028
}

0 commit comments

Comments
 (0)