Skip to content

Commit f6af42e

Browse files
author
Andrea Barbasso
committed
[UXP-155] fix tests
1 parent 8f57f71 commit f6af42e

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/metadataGroup/openstreetmap-group/openstreetmap-group.component.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ describe('OpenstreetmapGroupComponent', () => {
1717
let fixture: ComponentFixture<OpenstreetmapGroupComponent>;
1818

1919
const locationService = jasmine.createSpyObj('locationService', {
20-
searchPlace: jasmine.createSpy('searchPlace'),
21-
searchCoordinates: jasmine.createSpy('searchCoordinates'),
20+
findPlaceCoordinates: jasmine.createSpy('findPlaceCoordinates'),
21+
findPlaceAndDecimalCoordinates: jasmine.createSpy('findPlaceAndDecimalCoordinates'),
22+
searchByCoordinates: jasmine.createSpy('searchByCoordinates'),
23+
isValidDecimalCoordinatePair: jasmine.createSpy('isValidDecimalCoordinatePair'),
24+
isDecimalCoordinateString: jasmine.createSpy('isDecimalCoordinateString'),
25+
isSexagesimalCoordinateString: jasmine.createSpy('isSexagesimalCoordinateString'),
2226
isValidCoordinateString: jasmine.createSpy('isValidCoordinateString'),
2327
parseCoordinates: jasmine.createSpy('parseCoordinates'),
24-
isCoordinateString: jasmine.createSpy('isCoordinateString'),
2528
});
2629

2730
const place: LocationPlace = {
@@ -107,10 +110,10 @@ describe('OpenstreetmapGroupComponent', () => {
107110

108111
fixture = TestBed.createComponent(OpenstreetmapGroupComponent);
109112
component = fixture.componentInstance;
110-
locationService.isCoordinateString.and.returnValue(true);
113+
locationService.isDecimalCoordinateString.and.returnValue(true);
111114
locationService.isValidCoordinateString.and.returnValue(true);
112115
locationService.parseCoordinates.and.returnValue(place.coordinates);
113-
locationService.searchCoordinates.and.returnValue(of(place.displayName));
116+
locationService.searchByCoordinates.and.returnValue(of(place.displayName));
114117
fixture.detectChanges();
115118
});
116119

src/app/shared/open-street-map/open-street-map.component.spec.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ describe('OpenStreetMapComponent', () => {
99
let fixture: ComponentFixture<OpenStreetMapComponent>;
1010

1111
const locationService = jasmine.createSpyObj('locationService', {
12-
searchPlace: jasmine.createSpy('searchPlace'),
13-
searchCoordinates: jasmine.createSpy('searchCoordinates'),
12+
findPlaceCoordinates: jasmine.createSpy('findPlaceCoordinates'),
13+
findPlaceAndDecimalCoordinates: jasmine.createSpy('findPlaceAndDecimalCoordinates'),
14+
searchByCoordinates: jasmine.createSpy('searchByCoordinates'),
15+
isValidDecimalCoordinatePair: jasmine.createSpy('isValidDecimalCoordinatePair'),
16+
isDecimalCoordinateString: jasmine.createSpy('isDecimalCoordinateString'),
17+
isSexagesimalCoordinateString: jasmine.createSpy('isSexagesimalCoordinateString'),
1418
isValidCoordinateString: jasmine.createSpy('isValidCoordinateString'),
1519
parseCoordinates: jasmine.createSpy('parseCoordinates'),
16-
isCoordinateString: jasmine.createSpy('isCoordinateString'),
1720
});
1821

1922
const coordinates = '52.520008,13.404954';
@@ -65,14 +68,14 @@ describe('OpenStreetMapComponent', () => {
6568
describe('when coordinates are given', () => {
6669
beforeEach(() => {
6770
component.coordinates = coordinates;
68-
locationService.isCoordinateString.and.returnValue(true);
71+
locationService.isDecimalCoordinateString.and.returnValue(true);
6972
locationService.isValidCoordinateString.and.returnValue(true);
7073
locationService.parseCoordinates.and.returnValue(place.coordinates);
7174
});
7275

7376
describe('and they are found', () => {
7477
beforeEach(() => {
75-
locationService.searchCoordinates.and.returnValue(of(place.displayName));
78+
locationService.searchByCoordinates.and.returnValue(of(place.displayName));
7679
fixture.detectChanges();
7780
});
7881

@@ -88,7 +91,7 @@ describe('OpenStreetMapComponent', () => {
8891
describe('and they are not found', () => {
8992
beforeEach(() => {
9093

91-
locationService.searchCoordinates.and.callFake(() => {
94+
locationService.searchByCoordinates.and.callFake(() => {
9295
return throwError(() => new Error('Fake error'));
9396
});
9497
fixture.detectChanges();
@@ -107,12 +110,13 @@ describe('OpenStreetMapComponent', () => {
107110
describe('when address is given', () => {
108111
beforeEach(() => {
109112
component.coordinates = address;
110-
locationService.isCoordinateString.and.returnValue(false);
113+
locationService.isDecimalCoordinateString.and.returnValue(false);
111114
});
112115

113116
describe('and exists', () => {
114117
beforeEach(() => {
115-
locationService.searchPlace.and.returnValue(of(placeOnlyCoordinates));
118+
locationService.findPlaceCoordinates.and.returnValue(of(placeOnlyCoordinates));
119+
locationService.findPlaceAndDecimalCoordinates.and.returnValue(of(place));
116120
fixture.detectChanges();
117121
});
118122

@@ -128,7 +132,10 @@ describe('OpenStreetMapComponent', () => {
128132
describe('and is not found', () => {
129133
beforeEach(() => {
130134

131-
locationService.searchPlace.and.callFake(() => {
135+
locationService.findPlaceCoordinates.and.callFake(() => {
136+
return throwError(() => new Error(LocationErrorCodes.API_ERROR));
137+
});
138+
locationService.findPlaceAndDecimalCoordinates.and.callFake(() => {
132139
return throwError(() => new Error(LocationErrorCodes.API_ERROR));
133140
});
134141
fixture.detectChanges();

0 commit comments

Comments
 (0)