Skip to content

Commit

Permalink
chore: Upgrade Prettier (aws-amplify#13017)
Browse files Browse the repository at this point in the history
  • Loading branch information
cshfang committed Feb 15, 2024
1 parent b735feb commit 1fdbb12
Show file tree
Hide file tree
Showing 488 changed files with 4,033 additions and 4,005 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/1.bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ body:
Which major version of `aws-amplify` are you using?
multiple: false
options:
- v6
- v5
- Older than v5
- v6
- v5
- Older than v5
validations:
required: true
- type: dropdown
Expand Down Expand Up @@ -126,10 +126,10 @@ body:
How have you deployed the backend resources?
multiple: false
options:
- Amplify CLI
- Amplify Gen 2 (Preview)
- CDK
- Other
- Amplify CLI
- Amplify Gen 2 (Preview)
- CDK
- Other
- type: textarea
attributes:
label: Environment information
Expand Down
6 changes: 1 addition & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/** @type {import('jest').Config} */
module.exports = {
workerIdleMemoryLimit: '512MB',
coveragePathIgnorePatterns: [
'/node_modules/',
'dist',
'__tests__',
],
coveragePathIgnorePatterns: ['/node_modules/', 'dist', '__tests__'],
setupFiles: ['../../jest.setup.js'],
testEnvironment: 'jsdom',
testRegex: '/__tests__/.*\\.(test|spec)\\.[jt]sx?$',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"lerna": "^7.4.2",
"license-check-and-add": "^4.0.5",
"mkdirp": "^3.0.1",
"prettier": "^3.1.0",
"prettier": "^3.2.5",
"rimraf": "^2.6.2",
"rollup": "^4.9.6",
"size-limit": "^8.1.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/adapter-nextjs/__tests__/createServerRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jest.mock(
'../src/utils/createCookieStorageAdapterFromNextServerContext',
() => ({
createCookieStorageAdapterFromNextServerContext: jest.fn(),
})
}),
);

describe('createServerRunner', () => {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('createServerRunner', () => {
expect(mockRunWithAmplifyServerContextCore).toHaveBeenCalledWith(
mockAmplifyConfig,
{},
operation
operation,
);
});
});
Expand All @@ -106,11 +106,11 @@ describe('createServerRunner', () => {
const operation = jest.fn();
runWithAmplifyServerContext({ operation, nextServerContext: null });
expect(
mockCreateAWSCredentialsAndIdentityIdProvider
mockCreateAWSCredentialsAndIdentityIdProvider,
).toHaveBeenCalledWith(mockAmplifyConfig.Auth, sharedInMemoryStorage);
expect(mockCreateUserPoolsTokenProvider).toHaveBeenCalledWith(
mockAmplifyConfig.Auth,
sharedInMemoryStorage
sharedInMemoryStorage,
);
});
});
Expand All @@ -124,7 +124,7 @@ describe('createServerRunner', () => {
remove: jest.fn(),
};
mockCreateKeyValueStorageFromCookieStorageAdapter.mockReturnValueOnce(
mockCookieStorageAdapter
mockCookieStorageAdapter,
);
const mockNextServerContext = {
req: {
Expand All @@ -145,14 +145,14 @@ describe('createServerRunner', () => {
mockNextServerContext as unknown as NextServer.Context,
});
expect(
mockCreateAWSCredentialsAndIdentityIdProvider
mockCreateAWSCredentialsAndIdentityIdProvider,
).toHaveBeenCalledWith(
mockAmplifyConfig.Auth,
mockCookieStorageAdapter
mockCookieStorageAdapter,
);
expect(mockCreateUserPoolsTokenProvider).toHaveBeenCalledWith(
mockAmplifyConfig.Auth,
mockCookieStorageAdapter
mockCookieStorageAdapter,
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
({
get: mockGetFunc,
getAll: mockGetAllFunc,
}) as any
}) as any,
);

jest.spyOn(response, 'cookies', 'get').mockImplementation(() => ({
Expand All @@ -75,7 +75,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
it('gets cookie by calling `get` method of the underlying cookie store with a encoded cookie name', () => {
result.get(mockKeyWithEncoding);
expect(mockGetFunc).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding)
encodeURIComponent(mockKeyWithEncoding),
);
});

Expand All @@ -89,7 +89,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
expect(mockSetFunc).toHaveBeenCalledWith(
mockKey,
mockValue,
undefined /* didn't specify the options param in the call */
undefined /* didn't specify the options param in the call */,
);
});

Expand All @@ -98,7 +98,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
expect(mockSetFunc).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding),
mockValue,
{ sameSite: 'lax' }
{ sameSite: 'lax' },
);
});

Expand All @@ -110,7 +110,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
it('deletes cookie by calling the `delete` method of the underlying cookie store with a encoded cookie name', () => {
result.delete(mockKeyWithEncoding);
expect(mockDeleteFunc).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding)
encodeURIComponent(mockKeyWithEncoding),
);
});
});
Expand All @@ -124,13 +124,13 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
({
get: mockGetFunc,
getAll: mockGetAllFunc,
}) as any
}) as any,
);
jest.spyOn(response, 'headers', 'get').mockImplementation(
() =>
({
append: mockAppend,
}) as any
}) as any,
);

const mockContext = {
Expand All @@ -156,7 +156,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
it('gets cookie by calling `get` method of the underlying cookie store with a encoded cookie name', () => {
result.get(mockKeyWithEncoding);
expect(mockGetFunc).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding)
encodeURIComponent(mockKeyWithEncoding),
);
});

Expand All @@ -173,7 +173,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
mockSerializeOptions.domain
};Expires=${mockSerializeOptions.expires.toUTCString()};HttpOnly;SameSite=${
mockSerializeOptions.sameSite
};Secure`
};Secure`,
);
});

Expand All @@ -185,15 +185,15 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
mockSerializeOptions.domain
};Expires=${mockSerializeOptions.expires.toUTCString()};HttpOnly;SameSite=${
mockSerializeOptions.sameSite
};Secure`
};Secure`,
);
});

it('sets cookie by calling the `set` method of the underlying cookie store without options', () => {
result.set(mockKey, mockValue, undefined);
expect(mockAppend).toHaveBeenCalledWith(
'Set-Cookie',
`${mockKey}=${mockValue};`
`${mockKey}=${mockValue};`,
);
});

Expand All @@ -205,15 +205,15 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
});
expect(mockAppend).toHaveBeenCalledWith(
'Set-Cookie',
`${mockKey}=${mockValue};`
`${mockKey}=${mockValue};`,
);
});

it('deletes cookie by calling the `delete` method of the underlying cookie store', () => {
result.delete(mockKey);
expect(mockAppend).toHaveBeenCalledWith(
'Set-Cookie',
`${mockKey}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`
`${mockKey}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`,
);
});

Expand All @@ -222,8 +222,8 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
expect(mockAppend).toHaveBeenCalledWith(
'Set-Cookie',
`${encodeURIComponent(
mockKeyWithEncoding
)}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`
mockKeyWithEncoding,
)}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`,
);
});
});
Expand All @@ -241,7 +241,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
it('gets cookie by calling `get` method of the underlying cookie store with a encoded cookie name', () => {
result.get(mockKeyWithEncoding);
expect(mockNextCookiesFuncReturn.get).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding)
encodeURIComponent(mockKeyWithEncoding),
);
});

Expand All @@ -255,7 +255,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
expect(mockNextCookiesFuncReturn.set).toHaveBeenCalledWith(
mockKey,
mockValue,
undefined
undefined,
);
});

Expand All @@ -264,7 +264,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
expect(mockNextCookiesFuncReturn.set).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding),
mockValue,
undefined
undefined,
);
});

Expand All @@ -276,7 +276,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
it('deletes cookie by calling the `delete` method of the underlying cookie store with a encoded cookie name', () => {
result.delete(mockKeyWithEncoding);
expect(mockNextCookiesFuncReturn.delete).toHaveBeenCalledWith(
encodeURIComponent(mockKeyWithEncoding)
encodeURIComponent(mockKeyWithEncoding),
);
});
});
Expand Down Expand Up @@ -318,21 +318,21 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
});
expect(setHeaderSpy).toHaveBeenCalledWith(
'Set-Cookie',
'key4=value4;HttpOnly'
'key4=value4;HttpOnly',
);

result.delete('key3');
expect(setHeaderSpy).toHaveBeenCalledWith(
'Set-Cookie',
`key3=;Expires=${DATE_IN_THE_PAST.toUTCString()}`
`key3=;Expires=${DATE_IN_THE_PAST.toUTCString()}`,
);
});

it('operates with the underlying cookie store with encoded cookie names', () => {
// these the auth keys generated by Amplify
const encodedCookieName1 = encodeURIComponent('test@email.com.idToken');
const encodedCookieName2 = encodeURIComponent(
'test@email.com.refreshToken'
'test@email.com.refreshToken',
);

const mockCookies = {
Expand Down Expand Up @@ -375,18 +375,18 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
});

const encodedCookieName = encodeURIComponent(
'test@email.com.somethingElse'
'test@email.com.somethingElse',
);
result.set(encodeURIComponent('test@email.com.somethingElse'), 'value5');
expect(setHeaderSpy).toHaveBeenCalledWith(
'Set-Cookie',
`${encodeURIComponent(encodedCookieName)}=value5;`
`${encodeURIComponent(encodedCookieName)}=value5;`,
);

result.delete('key3');
expect(setHeaderSpy).toHaveBeenCalledWith(
'Set-Cookie',
`key3=;Expires=${DATE_IN_THE_PAST.toUTCString()}`
`key3=;Expires=${DATE_IN_THE_PAST.toUTCString()}`,
);
});
});
Expand All @@ -396,7 +396,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
createCookieStorageAdapterFromNextServerContext({
request: undefined,
response: new ServerResponse({} as any),
} as any)
} as any),
).toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const createCookieStorageAdapterFromGetServerSidePropsContext = (
? {
name,
value,
}
}
: undefined;
},
getAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const createRunWithAmplifyServerContext = ({
createCookieStorageAdapterFromNextServerContext(
nextServerContext,
),
);
);
const credentialsProvider = createAWSCredentialsAndIdentityIdProvider(
resourcesConfig.Auth,
keyValueStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Analytics Kinesis Firehose API: flushEvents', () => {
beforeEach(() => {
mockResolveConfig.mockReturnValue(mockKinesisConfig);
mockResolveCredentials.mockReturnValue(
Promise.resolve(mockCredentialConfig)
Promise.resolve(mockCredentialConfig),
);
mockGetEventBuffer.mockImplementation(() => ({
flushAll: mockFlushAll,
Expand All @@ -50,7 +50,7 @@ describe('Analytics Kinesis Firehose API: flushEvents', () => {
expect.objectContaining({
...mockKinesisConfig,
...mockCredentialConfig,
})
}),
);
expect(mockFlushAll).toHaveBeenCalledTimes(1);
});
Expand All @@ -62,7 +62,7 @@ describe('Analytics Kinesis Firehose API: flushEvents', () => {
await new Promise(process.nextTick);
expect(loggerWarnSpy).toHaveBeenCalledWith(
expect.any(String),
expect.any(Error)
expect.any(Error),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Analytics KinesisFirehose API: record', () => {
mockIsAnalyticsEnabled.mockReturnValue(true);
mockResolveConfig.mockReturnValue(mockKinesisConfig);
mockResolveCredentials.mockReturnValue(
Promise.resolve(mockCredentialConfig)
Promise.resolve(mockCredentialConfig),
);
mockGetEventBuffer.mockImplementation(() => ({
append: mockAppend,
Expand All @@ -60,7 +60,7 @@ describe('Analytics KinesisFirehose API: record', () => {
streamName: mockRecordInput.streamName,
event: mockRecordInput.data,
retryCount: 0,
})
}),
);
});

Expand All @@ -72,7 +72,7 @@ describe('Analytics KinesisFirehose API: record', () => {
await new Promise(process.nextTick);
expect(loggerWarnSpy).toHaveBeenCalledWith(
expect.any(String),
expect.any(Error)
expect.any(Error),
);
});

Expand Down
Loading

0 comments on commit 1fdbb12

Please sign in to comment.