diff --git a/packages/geo/__tests__/Geo.test.ts b/packages/geo/__tests__/Geo.test.ts index 1f331aff552..491bc60af48 100644 --- a/packages/geo/__tests__/Geo.test.ts +++ b/packages/geo/__tests__/Geo.test.ts @@ -1,12 +1,12 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { fetchAuthSession, Amplify } from '@aws-amplify/core'; +import { Amplify, fetchAuthSession } from '@aws-amplify/core'; import { + GetPlaceCommand, LocationClient, - SearchPlaceIndexForTextCommand, - SearchPlaceIndexForSuggestionsCommand, SearchPlaceIndexForPositionCommand, - GetPlaceCommand, + SearchPlaceIndexForSuggestionsCommand, + SearchPlaceIndexForTextCommand, } from '@aws-sdk/client-location'; import camelcaseKeys from 'camelcase-keys'; @@ -20,18 +20,17 @@ import { } from '../src/types'; import { - credentials, - awsConfig, TestPlacePascalCase, + awsConfig, + awsConfigGeoV4, + batchGeofencesCamelcaseResults, + credentials, + singleGeofenceCamelcaseResults, testPlaceCamelCase, - validGeometry, - validGeofences, validGeofence1, - singleGeofenceCamelcaseResults, - batchGeofencesCamelcaseResults, - awsConfigGeoV4, + validGeofences, + validGeometry, } from './testData'; - import { mockBatchPutGeofenceCommand, mockGetGeofenceCommand, @@ -73,6 +72,7 @@ LocationClient.prototype.send = jest.fn(async command => { jest.mock('@aws-amplify/core', () => { const originalModule = jest.requireActual('@aws-amplify/core'); + return { ...originalModule, fetchAuthSession: jest.fn(), @@ -173,10 +173,10 @@ describe('Geo', () => { const maps: AmazonLocationServiceMapStyle[] = []; const availableMaps = awsConfig.geo.amazon_location_service.maps.items; - const region = awsConfig.geo.amazon_location_service.region; + const { region } = awsConfig.geo.amazon_location_service; for (const mapName in availableMaps) { - const style = availableMaps[mapName].style; + const { style } = availableMaps[mapName]; maps.push({ mapName, style, region }); } @@ -223,9 +223,9 @@ describe('Geo', () => { const geo = new GeoClass(); const mapName = awsConfig.geo.amazon_location_service.maps.default; - const style = - awsConfig.geo.amazon_location_service.maps.items[mapName].style; - const region = awsConfig.geo.amazon_location_service.region; + const { style } = + awsConfig.geo.amazon_location_service.maps.items[mapName]; + const { region } = awsConfig.geo.amazon_location_service; const testMap = { mapName, style, region }; const defaultMapsResource = geo.getDefaultMap(); @@ -248,7 +248,7 @@ describe('Geo', () => { expect(results).toEqual([testPlaceCamelCase]); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -274,7 +274,7 @@ describe('Geo', () => { expect(results).toEqual([testPlaceCamelCase]); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: searchOptions.searchIndexName, @@ -303,7 +303,7 @@ describe('Geo', () => { expect(results).toEqual([testPlaceCamelCase]); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: searchOptions.searchIndexName, @@ -365,7 +365,7 @@ describe('Geo', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ PlaceId: testPlaceId, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -411,7 +411,7 @@ describe('Geo', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -436,7 +436,7 @@ describe('Geo', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: searchOptions.searchIndexName, @@ -464,7 +464,7 @@ describe('Geo', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: searchOptions.searchIndexName, @@ -527,7 +527,7 @@ describe('Geo', () => { expect(results).toEqual(testPlaceCamelCase); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Position: testCoordinates, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -553,7 +553,7 @@ describe('Geo', () => { expect(results).toEqual(testPlaceCamelCase); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Position: testCoordinates, IndexName: searchOptions.searchIndexName, @@ -595,7 +595,7 @@ describe('Geo', () => { // Expect that the API was called with the proper input const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; const output = { Entries: [ { @@ -674,7 +674,7 @@ describe('Geo', () => { // Expect that the API was called with the proper input const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; const output = { GeofenceId: 'testGeofenceId', CollectionName: 'geofenceCollectionExample', diff --git a/packages/geo/__tests__/Providers/AmazonLocationServiceProvider.test.ts b/packages/geo/__tests__/Providers/AmazonLocationServiceProvider.test.ts index e52aebf7ad3..391bde12b84 100644 --- a/packages/geo/__tests__/Providers/AmazonLocationServiceProvider.test.ts +++ b/packages/geo/__tests__/Providers/AmazonLocationServiceProvider.test.ts @@ -1,40 +1,40 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { fetchAuthSession, Amplify, GeoConfig } from '@aws-amplify/core'; +import { Amplify, fetchAuthSession } from '@aws-amplify/core'; import { + GetPlaceCommand, LocationClient, - SearchPlaceIndexForTextCommand, - SearchPlaceIndexForSuggestionsCommand, SearchPlaceIndexForPositionCommand, - GetPlaceCommand, + SearchPlaceIndexForSuggestionsCommand, + SearchPlaceIndexForTextCommand, } from '@aws-sdk/client-location'; +import camelcaseKeys from 'camelcase-keys'; import { AmazonLocationServiceProvider } from '../../src/providers/location-service/AmazonLocationServiceProvider'; import { - credentials, - awsConfig, TestPlacePascalCase, + awsConfig, + awsConfigGeoV4, + batchGeofencesCamelcaseResults, + clockwiseGeofence, + credentials, testPlaceCamelCase, validGeofences, - batchGeofencesCamelcaseResults, validGeometry, - clockwiseGeofence, - awsConfigGeoV4, } from '../testData'; import { createGeofenceInputArray, mockBatchPutGeofenceCommand, + mockDeleteGeofencesCommand, mockGetGeofenceCommand, mockListGeofencesCommand, - mockDeleteGeofencesCommand, } from '../testUtils'; import { - SearchByTextOptions, - SearchByCoordinatesOptions, - Coordinates, AmazonLocationServiceGeofence, + Coordinates, + SearchByCoordinatesOptions, + SearchByTextOptions, } from '../../src/types'; -import camelcaseKeys from 'camelcase-keys'; LocationClient.prototype.send = jest.fn(async command => { if ( @@ -71,6 +71,7 @@ LocationClient.prototype.send = jest.fn(async command => { jest.mock('@aws-amplify/core', () => { const originalModule = jest.requireActual('@aws-amplify/core'); + return { ...originalModule, fetchAuthSession: jest.fn(), @@ -126,9 +127,9 @@ describe('AmazonLocationServiceProvider', () => { const maps: any[] = []; const availableMaps = awsConfig.geo.amazon_location_service.maps.items; - const region = awsConfig.geo.amazon_location_service.region; + const { region } = awsConfig.geo.amazon_location_service; for (const mapName in availableMaps) { - const style = availableMaps[mapName].style; + const { style } = availableMaps[mapName]; maps.push({ mapName, style, region }); } @@ -168,9 +169,9 @@ describe('AmazonLocationServiceProvider', () => { const provider = new AmazonLocationServiceProvider(awsConfigGeoV4); const mapName = awsConfig.geo.amazon_location_service.maps.default; - const style = - awsConfig.geo.amazon_location_service.maps.items[mapName].style; - const region = awsConfig.geo.amazon_location_service.region; + const { style } = + awsConfig.geo.amazon_location_service.maps.items[mapName]; + const { region } = awsConfig.geo.amazon_location_service; const testMap = { mapName, style, region }; @@ -196,7 +197,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual([testPlaceCamelCase]); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -227,7 +228,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual([testPlaceCamelCase]); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, @@ -262,7 +263,7 @@ describe('AmazonLocationServiceProvider', () => { expect(resultsWithConstraints).toEqual([testPlaceCamelCase]); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: searchOptions.searchIndexName, @@ -364,7 +365,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -395,7 +396,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, @@ -428,7 +429,7 @@ describe('AmazonLocationServiceProvider', () => { expect(resultsWithConstraints).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Text: testString, IndexName: searchOptions.searchIndexName, @@ -524,7 +525,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual(testResults); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ PlaceId: testPlaceId, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -606,7 +607,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual(testPlaceCamelCase); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Position: testCoordinates, IndexName: awsConfig.geo.amazon_location_service.search_indices.default, @@ -634,7 +635,7 @@ describe('AmazonLocationServiceProvider', () => { expect(results).toEqual(testPlaceCamelCase); const spyon = jest.spyOn(LocationClient.prototype, 'send'); - const input = spyon.mock.calls[0][0].input; + const { input } = spyon.mock.calls[0][0]; expect(input).toEqual({ Position: testCoordinates, IndexName: searchOptions.searchIndexName, @@ -775,6 +776,7 @@ describe('AmazonLocationServiceProvider', () => { }), Errors: [], }; + return Promise.resolve(resolution); }); @@ -1084,6 +1086,7 @@ describe('AmazonLocationServiceProvider', () => { }, ], }; + return Promise.resolve(resolution); }); diff --git a/packages/geo/__tests__/testData.ts b/packages/geo/__tests__/testData.ts index e2d243d6cca..7c54e7b9277 100644 --- a/packages/geo/__tests__/testData.ts +++ b/packages/geo/__tests__/testData.ts @@ -1,17 +1,17 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import camelcaseKeys from 'camelcase-keys'; +import { GeoConfig } from '@aws-amplify/core'; +import { parseAWSExports } from '@aws-amplify/core/internals/utils'; import { Coordinates, - LinearRing, - GeofencePolygon, + Geofence, GeofenceInput, + GeofencePolygon, + LinearRing, PolygonGeometry, - Geofence, } from '../src/types'; -import { GeoConfig } from '@aws-amplify/core'; -import { parseAWSExports } from '@aws-amplify/core/internals/utils'; export const credentials = { accessKeyId: 'accessKeyId', diff --git a/packages/geo/__tests__/testUtils.ts b/packages/geo/__tests__/testUtils.ts index b2cab293c03..17b212bef39 100644 --- a/packages/geo/__tests__/testUtils.ts +++ b/packages/geo/__tests__/testUtils.ts @@ -1,13 +1,14 @@ import { + BatchDeleteGeofenceCommand, BatchPutGeofenceCommand, GetGeofenceCommand, ListGeofencesCommand, - BatchDeleteGeofenceCommand, } from '@aws-sdk/client-location'; -import { validPolygon, validGeometry } from './testData'; import { Geofence } from '../src/types'; +import { validGeometry, validPolygon } from './testData'; + export function createGeofenceInputArray(numberOfGeofences) { const geofences: Geofence[] = []; for (let i = 0; i < numberOfGeofences; i++) { @@ -16,6 +17,7 @@ export function createGeofenceInputArray(numberOfGeofences) { geometry: validGeometry, }); } + return geofences; } @@ -32,6 +34,7 @@ export function createGeofenceOutputArray(numberOfGeofences) { UpdateTime: '2020-04-01T21:00:00.000Z', }); } + return geofences; } @@ -76,6 +79,7 @@ export function mockListGeofencesCommand(command) { NextToken: 'THIS IS YOUR SECOND TOKEN', }; } + return { Entries: geofences.slice(0, 100), NextToken: 'THIS IS YOUR TOKEN', diff --git a/packages/geo/__tests__/util.test.ts b/packages/geo/__tests__/util.test.ts index 3ec7f10854f..765aee40464 100644 --- a/packages/geo/__tests__/util.test.ts +++ b/packages/geo/__tests__/util.test.ts @@ -2,64 +2,66 @@ // SPDX-License-Identifier: Apache-2.0 import { + mapSearchOptions, validateCoordinates, - validateLinearRing, - validatePolygon, validateGeofenceId, validateGeofencesInput, - mapSearchOptions, + validateLinearRing, + validatePolygon, } from '../src/util'; import { - invalidLngCoordinates, - invalidLatCoordinates, - infiniteCoordinates, - validLinearRing, clockwiseLinearRing, + geofenceWithTooManyVertices, + geofencesWithDuplicate, + geofencesWithInvalidId, + infiniteCoordinates, + invalidLatCoordinates, + invalidLngCoordinates, + linearRingBadCoordinates, linearRingIncomplete, linearRingTooSmall, - linearRingBadCoordinates, - validPolygon, + locationServiceInput, polygonTooBig, polygonTooManyVertices, - validGeofences, - geofencesWithDuplicate, - geofencesWithInvalidId, - geofenceWithTooManyVertices, searchOptions, searchOptionsMappedToInput, - locationServiceInput, + validGeofences, + validLinearRing, + validPolygon, } from './testData'; describe('Geo utility functions', () => { describe('validateCoordinates', () => { test('should not throw an error for valid coordinates', () => { validLinearRing.forEach(([lng, lat]) => { - expect(() => validateCoordinates(lng, lat)).not.toThrow(); + expect(() => { + validateCoordinates(lng, lat); + }).not.toThrow(); }); }); test('should error with message for bad longitude', () => { invalidLngCoordinates.forEach(([lng, lat]) => { - expect(() => validateCoordinates(lng, lat)).toThrow( - 'Longitude must be between -180 and 180 degrees inclusive.', - ); + expect(() => { + validateCoordinates(lng, lat); + }).toThrow('Longitude must be between -180 and 180 degrees inclusive.'); }); }); test('should error with message for bad latitude', () => { invalidLatCoordinates.forEach(([lng, lat]) => { - expect(() => validateCoordinates(lng, lat)).toThrow( - 'Latitude must be between -90 and 90 degrees inclusive.', - ); + expect(() => { + validateCoordinates(lng, lat); + }).toThrow('Latitude must be between -90 and 90 degrees inclusive.'); }); }); test('should error with message for coordinates with infinity', () => { infiniteCoordinates.forEach(([lng, lat]) => { - expect(() => validateCoordinates(lng, lat)).toThrow( - `Invalid coordinates: [${lng},${lat}]`, - ); + expect(() => { + validateCoordinates(lng, lat); + }).toThrow(`Invalid coordinates: [${lng},${lat}]`); }); }); }); @@ -70,33 +72,33 @@ describe('Geo utility functions', () => { expect(() => result).not.toThrow(); }); test('should error if first and last coordinates do not match', () => { - expect(() => - validateLinearRing(linearRingIncomplete, 'linearRingIncomplete'), - ).toThrow( + expect(() => { + validateLinearRing(linearRingIncomplete, 'linearRingIncomplete'); + }).toThrow( `linearRingIncomplete: LinearRing's first and last coordinates are not the same`, ); }); test('should error if LinearRing has less than 4 elements', () => { - expect(() => - validateLinearRing(linearRingTooSmall, 'linearRingTooSmall'), - ).toThrow( + expect(() => { + validateLinearRing(linearRingTooSmall, 'linearRingTooSmall'); + }).toThrow( 'linearRingTooSmall: LinearRing must contain 4 or more coordinates.', ); }); test('should error if any coordinates are not valid', () => { - expect(() => + expect(() => { validateLinearRing( linearRingBadCoordinates, 'linearRingBadCoordinates', - ), - ).toThrow( + ); + }).toThrow( 'linearRingBadCoordinates: One or more of the coordinates in the Polygon LinearRing are not valid: [{"coordinates":[181,0],"error":"Longitude must be between -180 and 180 degrees inclusive."},{"coordinates":[0,-91],"error":"Latitude must be between -90 and 90 degrees inclusive."}]', ); }); test('should error if the coordinates are not in counterclockwise order', () => { - expect(() => - validateLinearRing(clockwiseLinearRing, 'clockwiseLinearRing'), - ).toThrow( + expect(() => { + validateLinearRing(clockwiseLinearRing, 'clockwiseLinearRing'); + }).toThrow( 'clockwiseLinearRing: LinearRing coordinates must be wound counterclockwise', ); }); @@ -104,20 +106,24 @@ describe('Geo utility functions', () => { describe('validatePolygon', () => { test('should not throw an error for a valid Polygon', () => { - expect(() => validatePolygon(validPolygon)).not.toThrow(); + expect(() => { + validatePolygon(validPolygon); + }).not.toThrow(); }); test('should error if polygon is not a length of 1', () => { - expect(() => validatePolygon(polygonTooBig, 'polygonTooBig')).toThrow( + expect(() => { + validatePolygon(polygonTooBig, 'polygonTooBig'); + }).toThrow( `polygonTooBig: Polygon must have a single LinearRing array. Note: We do not currently support polygons with holes, multipolygons, polygons that are wound clockwise, or that cross the antimeridian.`, ); - expect(() => validatePolygon([], 'emptyPolygon')).toThrow( - `emptyPolygon: Polygon must have a single LinearRing array.`, - ); + expect(() => { + validatePolygon([], 'emptyPolygon'); + }).toThrow(`emptyPolygon: Polygon must have a single LinearRing array.`); }); test('should error if polygon has more than 1000 vertices', () => { - expect(() => - validatePolygon(polygonTooManyVertices, 'polygonTooManyVertices'), - ).toThrow( + expect(() => { + validatePolygon(polygonTooManyVertices, 'polygonTooManyVertices'); + }).toThrow( 'polygonTooManyVertices: Polygon has more than the maximum 1000 vertices.', ); }); @@ -125,35 +131,51 @@ describe('Geo utility functions', () => { describe('validateGeofenceId', () => { test('should not throw an error for a geofence ID with letters and numbers', () => { - expect(() => validateGeofenceId('ExampleGeofence1')).not.toThrow(); + expect(() => { + validateGeofenceId('ExampleGeofence1'); + }).not.toThrow(); }); test('should not throw an error for a geofence ID with a dash', () => { - expect(() => validateGeofenceId('ExampleGeofence-1')).not.toThrow(); + expect(() => { + validateGeofenceId('ExampleGeofence-1'); + }).not.toThrow(); }); test('should not throw an error for a geofence ID with a period', () => { - expect(() => validateGeofenceId('ExampleGeofence.1')).not.toThrow(); + expect(() => { + validateGeofenceId('ExampleGeofence.1'); + }).not.toThrow(); }); test('should not throw an error for a geofence ID with an underscore', () => { - expect(() => validateGeofenceId('ExampleGeofence_1')).not.toThrow(); + expect(() => { + validateGeofenceId('ExampleGeofence_1'); + }).not.toThrow(); }); test('should not throw an error for a geofence ID with non-basic Latin character', () => { - expect(() => validateGeofenceId('ExampleGeòfence-1')).not.toThrow(); + expect(() => { + validateGeofenceId('ExampleGeòfence-1'); + }).not.toThrow(); }); test('should not throw an error for a geofence ID with superscript and subscript numbers', () => { - expect(() => validateGeofenceId('ExampleGeofence-⁴₆')).not.toThrow(); + expect(() => { + validateGeofenceId('ExampleGeofence-⁴₆'); + }).not.toThrow(); }); test('should throw an error for an empty string', () => { - expect(() => validateGeofenceId('')).toThrow(); + expect(() => { + validateGeofenceId(''); + }).toThrow(); }); test('should throw an error for a geofence ID with an invalid character', () => { - expect(() => validateGeofenceId('ExampleGeofence-1&')).toThrow(); + expect(() => { + validateGeofenceId('ExampleGeofence-1&'); + }).toThrow(); }); }); @@ -163,18 +185,22 @@ describe('Geo utility functions', () => { expect(() => result).not.toThrow(); }); test('should error if a geofenceId is not unique', () => { - expect(() => validateGeofencesInput(geofencesWithDuplicate)).toThrow( - `Duplicate geofenceId: validGeofenceId1`, - ); + expect(() => { + validateGeofencesInput(geofencesWithDuplicate); + }).toThrow(`Duplicate geofenceId: validGeofenceId1`); }); test('should error if a geofenceId is not valid', () => { - expect(() => validateGeofencesInput(geofencesWithInvalidId)).toThrow( + expect(() => { + validateGeofencesInput(geofencesWithInvalidId); + }).toThrow( `Invalid geofenceId: 't|-|!$ !$ N()T V@|_!D' - IDs can only contain alphanumeric characters, hyphens, underscores and periods.`, ); }); }); test('should error if polygon has more than 1000 vertices', () => { - expect(() => validateGeofencesInput([geofenceWithTooManyVertices])).toThrow( + expect(() => { + validateGeofencesInput([geofenceWithTooManyVertices]); + }).toThrow( `Geofence 'geofenceWithTooManyVertices' has more than the maximum of 1000 vertices`, ); });