Skip to content

Commit

Permalink
fix: update parseAWSExports
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Kumar committed Apr 27, 2024
1 parent c023153 commit 438f25c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
31 changes: 31 additions & 0 deletions packages/core/__tests__/parseAWSExports.test.ts
Expand Up @@ -27,6 +27,10 @@ describe('parseAWSExports', () => {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
geofenceCollections: {
items: ['geofenceCollection-dev'],
default: 'geofenceCollection-dev',
},
region,
};
const amazonLocationServiceV4 = {
Expand All @@ -49,6 +53,10 @@ describe('parseAWSExports', () => {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
geofenceCollections: {
items: ['geofenceCollection-dev'],
default: 'geofenceCollection-dev',
},
region,
};
const restEndpoint1 = {
Expand Down Expand Up @@ -189,6 +197,29 @@ describe('parseAWSExports', () => {
).toStrictEqual(expected);
});

it('should parse valid aws-exports.js for Geo', () => {
const expected = {
Geo: {
LocationService: amazonLocationServiceV4,
},
};
// aws-exports.js has geo "search_indices" in snake_case
expect(
parseAWSExports({
aws_project_region: 'us-west-2',
geo: { amazon_location_service: amazonLocationService },
}),
).toStrictEqual(expected);

// aws-exports.js has geo "searchIndices" in camelCase
expect(
parseAWSExports({
aws_project_region: 'us-west-2',
geo: { amazon_location_service: amazonLocationServiceV4 },
}),
).toStrictEqual(expected);
});

it('should fallback to IAM auth mode if Appsync auth type is invalid', () => {
expect(
parseAWSExports({
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/parseAWSExports.ts
Expand Up @@ -252,9 +252,12 @@ export const parseAWSExports = (
(amplifyConfig as any).Geo = amazon_location_service
? {
LocationService: {
...amazon_location_service,
maps: amazon_location_service.maps,
geofenceCollections: amazon_location_service.geofenceCollections,
searchIndices: amazon_location_service.search_indices,
searchIndices:
amazon_location_service.search_indices ??
amazon_location_service.searchIndices,
region: amazon_location_service.region,
},
}
Expand Down

0 comments on commit 438f25c

Please sign in to comment.