Skip to content

Commit

Permalink
Test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Jul 5, 2024
1 parent ad3d9a4 commit 4de8c22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ public void UpdateProperties_MatchProperties_NewProperty_Success()
RegionCode = 1,
}
);
propertyService.Setup(x => x.PopulateNewFileProperty(It.IsAny<PimsPropertyAcquisitionFile>())).Returns<PimsPropertyAcquisitionFile>(x => x);

var userRepository = this._helper.GetService<Mock<IUserRepository>>();
userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny<Guid>())).Returns(EntityHelper.CreateUser(1, Guid.NewGuid(), "Test", regionCode: 1));
Expand Down
49 changes: 29 additions & 20 deletions source/frontend/src/utils/mapPropertyUtils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const expectedMapProperty = {
landArea: 647.4646,
latitude: 48.432802005,
longitude: -123.310041775,
legalDescription: undefined,
name: undefined,
pid: '000002500',
pin: undefined,
Expand All @@ -39,6 +40,10 @@ const expectedMapProperty = {
coordinates: [[[-123.31014591, 48.43274258]]],
type: 'Polygon',
},
fileLocation: {
lat: 48.432802005,
lng: -123.310041775,
},
propertyId: undefined,
region: 1,
regionName: 'South Coast',
Expand Down Expand Up @@ -90,32 +95,28 @@ describe('mapPropertyUtils', () => {
[{ address: '' }, { label: NameSourceType.NONE, value: '' }],
[{ address: '1234 fake st' }, { label: NameSourceType.ADDRESS, value: '1234 fake st' }],
])(
'getPropertyName test with source %p expecting %p',
'getPropertyName test with source %o expecting %o',
(mapProperty: IMapProperty, expectedName: PropertyName) => {
const actualName = getPropertyName(mapProperty);
expect(actualName.label).toEqual(expectedName.label);
expect(actualName.value).toEqual(expectedName.value);
},
);

it('getPrettyLatLng, empty', () => {
const prettyLatLng = getPrettyLatLng(undefined);
expect(prettyLatLng).toEqual('');
});

it('getPrettyLatLng, valued', () => {
const prettyLatLng = getPrettyLatLng({ coordinate: { x: 1, y: 2 } });
expect(prettyLatLng).toEqual('1.000000, 2.000000');
});

it('getLatLng, empty', () => {
const latLng = getLatLng(undefined);
expect(latLng).toEqual(null);
it.each([
['empty', undefined, ''],
['valued', { coordinate: { x: 1, y: 2 } }, '1.000000, 2.000000'],
])('getPrettyLatLng - %s', (_, value, expected) => {
const prettyLatLng = getPrettyLatLng(value);
expect(prettyLatLng).toEqual(expected);
});

it('getLatLng, valued', () => {
const latLng = getLatLng({ coordinate: { x: 1, y: 2 } });
expect(latLng).toEqual({ lat: 2, lng: 1 });
it.each([
['empty', undefined, null],
['valued', { coordinate: { x: 1, y: 2 } }, { lat: 2, lng: 1 }],
])('getLatLng - %s', (_, value, expected) => {
const latLng = getLatLng(value);
expect(latLng).toEqual(expected);
});

it.each([
Expand Down Expand Up @@ -152,7 +153,7 @@ describe('mapPropertyUtils', () => {
{ ...getEmptyFileProperty(), property: { ...getEmptyProperty(), pid: 1 } },
],
])(
'getFilePropertyName test with ignore name flag %p expecting %p source %p',
'getFilePropertyName test with ignore name flag %o expecting %s source %o',
(skipName: boolean, expectedName: PropertyName, mapProperty?: ApiGen_Concepts_FileProperty) => {
const fileName = getFilePropertyName(mapProperty, skipName);
expect(fileName.label).toEqual(expectedName.label);
Expand Down Expand Up @@ -183,6 +184,10 @@ describe('mapPropertyUtils', () => {
propertyId: undefined,
region: undefined,
regionName: undefined,
fileLocation: {
lat: 48.76613749999999,
lng: -123.46163749999998,
},
},
],
],
Expand All @@ -207,11 +212,15 @@ describe('mapPropertyUtils', () => {
propertyId: undefined,
region: undefined,
regionName: undefined,
fileLocation: {
lat: 48.76613749999999,
lng: -123.46163749999998,
},
},
],
],
])(
'featuresToIdentifiedMapProperty test with feature values %p and address %p and expected map properties %p',
'featuresToIdentifiedMapProperty test with feature values %o and address %o and expected map properties %o',
(
values: FeatureCollection<Geometry, GeoJsonProperties> | undefined,
address?: string,
Expand Down Expand Up @@ -242,7 +251,7 @@ describe('mapPropertyUtils', () => {
{ ...expectedMapProperty, address: 'address' },
],
])(
'featuresetToMapProperty test with feature set %p address %p expectedPropertyFile %p',
'featuresetToMapProperty test with feature set %o address %o expectedPropertyFile %o',
(
featureSet: LocationFeatureDataset,
address: string = 'unknown',
Expand Down

0 comments on commit 4de8c22

Please sign in to comment.