Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cshfang committed Nov 27, 2023
1 parent b6af858 commit 8519c4b
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 35 deletions.
5 changes: 0 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ module.exports = {
coveragePathIgnorePatterns: [
'/node_modules/',
'dist',
'lib',
'lib-esm',
'__tests__',
],
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
setupFiles: ['../../jest.setup.js'],
testEnvironment: 'jsdom',
testRegex: '/__tests__/.*\\.(test|spec)\\.[jt]sx?$',
Expand Down
3 changes: 3 additions & 0 deletions packages/analytics/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ module.exports = {
statements: 68,
},
},
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ describe('AWSAppSyncRealTimeProvider', () => {
expect(e.errors[0].message).toEqual(
'Connection failed: Non-retriable Test'
);
// done();
},
});

Expand Down
41 changes: 19 additions & 22 deletions packages/api-graphql/__tests__/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
import { Hub } from '@aws-amplify/core';
import { Observable, Observer } from 'rxjs';
import { CONNECTION_STATE_CHANGE } from '../src/Providers/constants';
Expand All @@ -16,13 +15,11 @@ export function delay(timeout) {
export class HubConnectionListener {
teardownHubListener: () => void;
observedConnectionStates: CS[] = [];
currentConnectionState: CS;
currentConnectionState!: CS;

private connectionStateObservers: Observer<CS>[] = [];

constructor(channel: string) {
let closeResolver: (value: PromiseLike<any>) => void;

this.teardownHubListener = Hub.listen(channel, (data: any) => {
const { payload } = data;
if (payload.event === CONNECTION_STATE_CHANGE) {
Expand Down Expand Up @@ -88,12 +85,12 @@ export class HubConnectionListener {
}

export class FakeWebSocketInterface {
webSocket: FakeWebSocket;
readyForUse: Promise<void>;
hasClosed: Promise<undefined>;
webSocket!: FakeWebSocket;
readyForUse!: Promise<void>;
hasClosed!: Promise<undefined>;
hubConnectionListener: HubConnectionListener;

private readyResolve: (value: PromiseLike<any>) => void;
private readyResolve!: (value: PromiseLike<any>) => void;

constructor() {
this.hubConnectionListener = new HubConnectionListener('api');
Expand Down Expand Up @@ -300,16 +297,16 @@ class FakeWebSocket implements WebSocket {
subscriptionId: string | undefined;
closeResolverFcn: () => (value: PromiseLike<any>) => void;

binaryType: BinaryType;
bufferedAmount: number;
extensions: string;
onclose: (this: WebSocket, ev: CloseEvent) => any;
onerror: (this: WebSocket, ev: Event) => any;
onmessage: (this: WebSocket, ev: MessageEvent) => any;
onopen: (this: WebSocket, ev: Event) => any;
protocol: string;
readyState: number;
url: string;
binaryType!: BinaryType;
bufferedAmount!: number;
extensions!: string;
onclose!: (this: WebSocket, ev: CloseEvent) => any;
onerror!: (this: WebSocket, ev: Event) => any;
onmessage!: (this: WebSocket, ev: MessageEvent) => any;
onopen!: (this: WebSocket, ev: Event) => any;
protocol!: string;
readyState!: number;
url!: string;
close(code?: number, reason?: string): void {
const closeResolver = this.closeResolverFcn();
if (closeResolver) closeResolver(Promise.resolve(undefined));
Expand Down Expand Up @@ -355,10 +352,10 @@ class FakeWebSocket implements WebSocket {
constructor(closeResolver: () => (value: PromiseLike<any>) => void) {
this.closeResolverFcn = closeResolver;
}
CONNECTING: 0;
OPEN: 1;
CLOSING: 2;
CLOSED: 3;
CONNECTING: 0 = 0;
OPEN: 1 = 1;
CLOSING: 2 = 2;
CLOSED: 3 = 3;
}

export async function replaceConstant(
Expand Down
2 changes: 1 addition & 1 deletion packages/api-rest/src/utils/createCancellableOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function createCancellableOperation(
return response;
} catch (error: any) {
const abortSignal = internalPostAbortSignal ?? publicApisAbortSignal;
const message = abortSignal.reason ?? abortReason;
const message = abortReason ?? abortSignal.reason;
if (error.name === 'AbortError' || abortSignal?.aborted === true) {
const canceledError = new CanceledError({
...(message && { message }),
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-amplify/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ module.exports = {
statements: 91,
},
},
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
};
2 changes: 1 addition & 1 deletion packages/core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
coverageThreshold: {
global: {
branches: 75,
functions: 78,
functions: 72,
lines: 88,
statements: 88,
},
Expand Down
3 changes: 3 additions & 0 deletions packages/geo/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ module.exports = {
statements: 89,
},
},
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
};
3 changes: 3 additions & 0 deletions packages/interactions/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ module.exports = {
statements: 96,
},
},
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
};
3 changes: 3 additions & 0 deletions packages/predictions/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ module.exports = {
statements: 89,
},
},
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
};
3 changes: 3 additions & 0 deletions packages/pubsub/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ module.exports = {
statements: 28,
},
},
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
};
5 changes: 0 additions & 5 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8519c4b

Please sign in to comment.