Skip to content

Commit

Permalink
AB#42477- contact details
Browse files Browse the repository at this point in the history
  • Loading branch information
eserkansozer committed Sep 25, 2020
1 parent 485bed2 commit d2342c3
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/contact-details/contact-details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ <h1 class="govuk-heading-xl">Contact details</h1>
</div>
</div>

<div [hidden]='resultSectionState === "list-view"'>
<div id="mapWrapper" [hidden]='resultSectionState === "list-view"'>
<app-contact-map [visibleSchoolList]='visibleSchoolList'></app-contact-map>
</div>

<div [hidden]='resultSectionState === "map-view"'>
<div id="listWrapper" [hidden]='resultSectionState === "map-view"'>
<div *ngIf='!isMobileScreen' id="schoolList">
<div *ngFor='let neighbour of visibleSchoolList; let i = index'>
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
Expand Down
100 changes: 100 additions & 0 deletions src/app/contact-details/contact-details.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('ContactDetailsComponent', () => {

fixture = TestBed.createComponent(ContactDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should display mobile version when screen size is in mobile limits', () => {
Expand All @@ -75,4 +76,103 @@ describe('ContactDetailsComponent', () => {
expect(mTable).toBeNull();
});

it('should display map view version when selected', () => {
activatedRouteStub.setParamMap({ urn: 123 });
component.resultSectionState = "map-view";

fixture.detectChanges();

let mapWrapper = fixture.debugElement.query(By.css('#mapWrapper'));
expect(mapWrapper).toBeDefined();

let hiddenMapWrapper = fixture.debugElement.query(By.css('#mapWrapper[hidden]'));
expect(hiddenMapWrapper).toBeNull();

});

it('should display list view version when selected', () => {
activatedRouteStub.setParamMap({ urn: 123 });
component.resultSectionState = "list-view";

fixture.detectChanges();

let listWrapper = fixture.debugElement.query(By.css('#listWrapper'));
expect(listWrapper).toBeDefined();

let hiddenListWrapper = fixture.debugElement.query(By.css('#listWrapper[hidden]'));
expect(hiddenListWrapper).toBeNull();

});

it('should sort visible school list by rank', () => {
activatedRouteStub.setParamMap({ urn: 123 });
let stubEmModel = new EMModel();
let stubNeigbourModel1 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel1.rank = 1;
let stubNeigbourModel2 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel2.rank = 2;
let stubNeigbourModel3 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel3.rank = 3;
stubEmModel.neighbourDataModels = [stubNeigbourModel3, stubNeigbourModel2, stubNeigbourModel1]
emDataServiceSpy.getEmData.and.returnValue(of(stubEmModel));

fixture = TestBed.createComponent(ContactDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();

component.sortSchools();

expect(component.visibleSchoolList[0]).toEqual(stubNeigbourModel1);
expect(component.visibleSchoolList[1]).toEqual(stubNeigbourModel2);
expect(component.visibleSchoolList[2]).toEqual(stubNeigbourModel3);
});

it('should sort visible school list by name asc', () => {
activatedRouteStub.setParamMap({ urn: 123 });
let stubEmModel = new EMModel();
let stubNeigbourModel1 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel1.name = "a";
let stubNeigbourModel2 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel2.name = "b";
let stubNeigbourModel3 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel3.name = "c";
stubEmModel.neighbourDataModels = [stubNeigbourModel3, stubNeigbourModel2, stubNeigbourModel1]
emDataServiceSpy.getEmData.and.returnValue(of(stubEmModel));

fixture = TestBed.createComponent(ContactDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();

component.sort = 'AlphabeticalAZ';
component.sortSchools();

expect(component.visibleSchoolList[0]).toEqual(stubNeigbourModel1);
expect(component.visibleSchoolList[1]).toEqual(stubNeigbourModel2);
expect(component.visibleSchoolList[2]).toEqual(stubNeigbourModel3);
});

it('should sort visible school list by name desc', () => {
activatedRouteStub.setParamMap({ urn: 123 });
let stubEmModel = new EMModel();
let stubNeigbourModel1 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel1.name = "a";
let stubNeigbourModel2 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel2.name = "b";
let stubNeigbourModel3 = new EfficiencyMetricNeighbourModel();
stubNeigbourModel3.name = "c";
stubEmModel.neighbourDataModels = [stubNeigbourModel3, stubNeigbourModel2, stubNeigbourModel1]
emDataServiceSpy.getEmData.and.returnValue(of(stubEmModel));

fixture = TestBed.createComponent(ContactDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();

component.sort = 'AlphabeticalZA';
component.sortSchools();

expect(component.visibleSchoolList[0]).toEqual(stubNeigbourModel3);
expect(component.visibleSchoolList[1]).toEqual(stubNeigbourModel2);
expect(component.visibleSchoolList[2]).toEqual(stubNeigbourModel1);
});

});
1 change: 0 additions & 1 deletion src/app/core/config/app-config.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function configLoaderFactory(http: HttpClient): ConfigLoader {
}

export function appSettingsFactory(configService: ConfigService, urlService: URLService): AppSettings {
debugger;
const appsettings: AppSettings = configService.getSettings().appSettings;
appsettings.domain = urlService.getDomain();
return appsettings;
Expand Down
1 change: 0 additions & 1 deletion src/app/manual-comparison/manual-comparison.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class ManualComparisonComponent implements OnInit, AfterViewInit {
}

ngAfterViewInit(){
debugger;
this.religionFilter.buildReligionFiltersFromDataModel(this.visibleSchoolList);
}

Expand Down

0 comments on commit d2342c3

Please sign in to comment.