Skip to content

Commit

Permalink
lint --fix run
Browse files Browse the repository at this point in the history
  • Loading branch information
ashika112 committed May 28, 2024
1 parent f4c9ca1 commit 7ec6b28
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 120 deletions.
56 changes: 28 additions & 28 deletions packages/geo/__tests__/Geo.test.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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 });
}

Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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 });
}

Expand Down Expand Up @@ -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 };

Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -775,6 +776,7 @@ describe('AmazonLocationServiceProvider', () => {
}),
Errors: [],
};

return Promise.resolve(resolution);
});

Expand Down Expand Up @@ -1084,6 +1086,7 @@ describe('AmazonLocationServiceProvider', () => {
},
],
};

return Promise.resolve(resolution);
});

Expand Down
10 changes: 5 additions & 5 deletions packages/geo/__tests__/testData.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Loading

0 comments on commit 7ec6b28

Please sign in to comment.