-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6435 from NMDSdevopsServiceAdm/feature-branch/fun…
…ding-redesign Feature branch/funding redesign
- Loading branch information
Showing
105 changed files
with
6,046 additions
and
4,367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
frontend/src/app/core/resolvers/funding-report.resolver.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ActivatedRouteSnapshot, convertToParamMap } from '@angular/router'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { EstablishmentService } from '@core/services/establishment.service'; | ||
import { ReportService } from '@core/services/report.service'; | ||
import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; | ||
import { of } from 'rxjs'; | ||
|
||
import { FundingReportResolver } from './funding-report.resolver'; | ||
|
||
describe('FundingReportResolver', () => { | ||
function setup(overrides: any = {}) { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])], | ||
providers: [ | ||
FundingReportResolver, | ||
{ | ||
provide: EstablishmentService, | ||
useClass: MockEstablishmentService, | ||
}, | ||
{ | ||
provide: ActivatedRouteSnapshot, | ||
useValue: { | ||
paramMap: convertToParamMap({ establishmentuid: overrides.idInParams ?? null }), | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
const resolver = TestBed.inject(FundingReportResolver); | ||
const route = TestBed.inject(ActivatedRouteSnapshot); | ||
|
||
const reportService = TestBed.inject(ReportService); | ||
const getWDFReportSpy = spyOn(reportService, 'getWDFReport').and.returnValue(of(null)); | ||
|
||
return { | ||
resolver, | ||
route, | ||
getWDFReportSpy, | ||
}; | ||
} | ||
|
||
it('should create', () => { | ||
const { resolver } = setup(); | ||
|
||
expect(resolver).toBeTruthy(); | ||
}); | ||
|
||
it('should call getWDFReport with id from establishmentService when no uid in params', () => { | ||
const { resolver, route, getWDFReportSpy } = setup(); | ||
|
||
const idFromEstablishmentService = '98a83eef-e1e1-49f3-89c5-b1287a3cc8dd'; | ||
|
||
resolver.resolve(route); | ||
|
||
expect(getWDFReportSpy).toHaveBeenCalledWith(idFromEstablishmentService); | ||
}); | ||
|
||
it('should call getWDFReport with uid in params when there', () => { | ||
const idInParams = '12321nuihniuh4324'; | ||
|
||
const { resolver, route, getWDFReportSpy } = setup({ idInParams }); | ||
|
||
resolver.resolve(route); | ||
|
||
expect(getWDFReportSpy).toHaveBeenCalledWith(idInParams); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
frontend/src/app/core/resolvers/funding-report.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router'; | ||
import { EstablishmentService } from '@core/services/establishment.service'; | ||
import { ReportService } from '@core/services/report.service'; | ||
import { of } from 'rxjs'; | ||
import { catchError } from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class FundingReportResolver implements Resolve<any> { | ||
constructor( | ||
private router: Router, | ||
private reportService: ReportService, | ||
private establishmentService: EstablishmentService, | ||
) {} | ||
|
||
resolve(route: ActivatedRouteSnapshot) { | ||
const workplaceUid = route.paramMap.get('establishmentuid') ?? this.establishmentService.establishmentId; | ||
|
||
return this.reportService.getWDFReport(workplaceUid).pipe( | ||
catchError(() => { | ||
this.router.navigate(['/dashboard']); | ||
return of(null); | ||
}), | ||
); | ||
} | ||
} |
Oops, something went wrong.