Skip to content

Commit

Permalink
Ran prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDDM committed Jan 22, 2025
1 parent 37f7086 commit 75db2ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/apiClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch, { Request, Response } from 'node-fetch';
import type { AbortSignal } from 'node-fetch/externals.js';
import { AbortSignal } from 'node-fetch/externals.js';
import { NylasConfig, OverridableNylasConfig } from './config.js';
import {
NylasApiError,
Expand Down Expand Up @@ -153,7 +153,9 @@ export default class APIClient {
}, timeoutDuration);

try {
const response = await fetch(req, { signal: controller.signal as AbortSignal });
const response = await fetch(req, {
signal: controller.signal as AbortSignal,
});
clearTimeout(timeout);

if (typeof response === 'undefined') {
Expand Down
20 changes: 17 additions & 3 deletions tests/apiClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { RequestInfo } from 'node-fetch';
import APIClient, { RequestOptionsParams } from '../src/apiClient';
import { NylasApiError, NylasOAuthError, NylasSdkTimeoutError } from '../src/models/error';
import {
NylasApiError,
NylasOAuthError,
NylasSdkTimeoutError,
} from '../src/models/error';
import { SDK_VERSION } from '../src/version';
import { mockedFetch, mockResponse } from './testUtils';

Expand Down Expand Up @@ -327,7 +331,12 @@ describe('APIClient', () => {
method: 'GET',
overrides: { timeout: overrideTimeout },
})
).rejects.toThrow(new NylasSdkTimeoutError('https://api.us.nylas.com/test', overrideTimeout * 1000));
).rejects.toThrow(
new NylasSdkTimeoutError(
'https://api.us.nylas.com/test',
overrideTimeout * 1000
)
);
});

it('should use default timeout when no override provided', async () => {
Expand All @@ -343,7 +352,12 @@ describe('APIClient', () => {
path: '/test',
method: 'GET',
})
).rejects.toThrow(new NylasSdkTimeoutError('https://api.us.nylas.com/test', client.timeout));
).rejects.toThrow(
new NylasSdkTimeoutError(
'https://api.us.nylas.com/test',
client.timeout
)
);
});

it('should complete request within timeout period', async () => {
Expand Down

0 comments on commit 75db2ad

Please sign in to comment.