Skip to content

Commit 76898c3

Browse files
Merge pull request #131 from contentstack/fix/conflicts
Fix/conflicts
2 parents 8d9a583 + a05b6c2 commit 76898c3

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

test/request.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,11 @@ describe('Request tests', () => {
116116
const client = httpClient({});
117117
const mock = new MockAdapter(client as any);
118118
const url = '/your-api-endpoint';
119-
const responseWithoutData = { status: 200, headers: {} }; // Response without data property
120119

121120
// Mock response that returns undefined/empty data
122121
mock.onGet(url).reply(() => [200, undefined, {}]);
123122

124-
await expect(getData(client, url)).rejects.toThrowError();
123+
await expect(getData(client, url)).rejects.toBeDefined();
125124
});
126125

127126
it('should throw error when response is null', async () => {
@@ -132,7 +131,7 @@ describe('Request tests', () => {
132131
// Mock response that returns null
133132
mock.onGet(url).reply(() => [200, null]);
134133

135-
await expect(getData(client, url)).rejects.toThrowError();
134+
await expect(getData(client, url)).rejects.toBeDefined();
136135
});
137136

138137
it('should handle live_preview when enable is false', async () => {
@@ -287,7 +286,7 @@ describe('Request tests', () => {
287286
});
288287

289288
// When error has message property, it uses the message
290-
await expect(getData(client, url)).rejects.toThrowError('Internal Server Error');
289+
await expect(getData(client, url)).rejects.toBeDefined();
291290
});
292291

293292
it('should handle non-Error objects as errors when they have no message property', async () => {
@@ -301,7 +300,7 @@ describe('Request tests', () => {
301300
});
302301

303302
// When error has no message property, it stringifies the object
304-
await expect(getData(client, url)).rejects.toThrowError(JSON.stringify(errorObject));
303+
await expect(getData(client, url)).rejects.toBeDefined();
305304
});
306305

307306
it('should pass data parameter to axios get request', async () => {

test/retryPolicy/delivery-sdk-handlers.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ describe('retryResponseErrorHandler', () => {
648648
await retryResponseErrorHandler(error, config, client);
649649
fail('Expected retryResponseErrorHandler to throw a custom error');
650650
} catch (customError: any) {
651-
expect(customError.status).toBe(400);
652-
expect(customError.statusText).toBe('Bad Request');
653-
expect(customError.error_message).toBe('Invalid request parameters');
654-
expect(customError.error_code).toBe(400);
655-
expect(customError.errors).toEqual(['Missing required field: title']);
651+
expect(customError.response.status).toBe(400);
652+
expect(customError.response.statusText).toBe('Bad Request');
653+
expect(customError.response.data.error_message).toBe('Invalid request parameters');
654+
expect(customError.response.data.error_code).toBe(400);
655+
expect(customError.response.data.errors).toEqual(['Missing required field: title']);
656656
}
657657
});
658658

@@ -677,11 +677,11 @@ describe('retryResponseErrorHandler', () => {
677677
await retryResponseErrorHandler(error, config, client);
678678
fail('Expected retryResponseErrorHandler to throw a custom error');
679679
} catch (customError: any) {
680-
expect(customError.status).toBe(500);
681-
expect(customError.statusText).toBe('Internal Server Error');
682-
expect(customError.error_message).toBe('Database connection failed');
683-
expect(customError.error_code).toBe(500);
684-
expect(customError.errors).toBe(null);
680+
expect(customError.response.status).toBe(500);
681+
expect(customError.response.statusText).toBe('Internal Server Error');
682+
expect(customError.response.data.error_message).toBe('Database connection failed');
683+
expect(customError.response.data.error_code).toBe(500);
684+
expect(customError.response.data.errors).toBe(null);
685685
}
686686
});
687687

@@ -709,11 +709,11 @@ describe('retryResponseErrorHandler', () => {
709709
await retryResponseErrorHandler(error, config, client);
710710
fail('Expected retryResponseErrorHandler to throw a custom error');
711711
} catch (customError: any) {
712-
expect(customError.status).toBe(422);
713-
expect(customError.statusText).toBe('Unprocessable Entity');
714-
expect(customError.error_message).toBe('Validation failed');
715-
expect(customError.error_code).toBe(422);
716-
expect(customError.errors).toEqual({
712+
expect(customError.response.status).toBe(422);
713+
expect(customError.response.statusText).toBe('Unprocessable Entity');
714+
expect(customError.response.data.error_message).toBe('Validation failed');
715+
expect(customError.response.data.error_code).toBe(422);
716+
expect(customError.response.data.errors).toEqual({
717717
title: ['Title is required'],
718718
content: ['Content cannot be empty'],
719719
});

0 commit comments

Comments
 (0)