Skip to content

Commit de9cff8

Browse files
committed
use updated jest methods for jest 30 toThrowError -> toThrow
1 parent b191f7e commit de9cff8

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

contentcuration/contentcuration/frontend/shared/__tests__/feedbackUtils.spec.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('FeedBackUtility Tests', () => {
104104

105105
it('should throw an error when endpoint is not defined', () => {
106106
flagFeedbackEvent.endpoint = undefined;
107-
expect(() => flagFeedbackEvent.getUrl()).toThrowError(
107+
expect(() => flagFeedbackEvent.getUrl()).toThrow(
108108
'Resource is not defined for the FeedBack Object.',
109109
);
110110
});
@@ -130,7 +130,7 @@ describe('FeedBackUtility Tests', () => {
130130

131131
it.skip('should handle errors when sending a request using sendRequest function', async () => {
132132
client.post.mockRejectedValue(new Error('Mocked API Error'));
133-
await expect(sendRequest(flagFeedbackEvent)).rejects.toThrowError('Mocked API Error');
133+
await expect(sendRequest(flagFeedbackEvent)).rejects.toThrow('Mocked API Error');
134134
expect(client.post).toHaveBeenCalledWith(
135135
flagFeedbackEvent.getUrl(),
136136
flagFeedbackEvent.getData(),
@@ -160,7 +160,7 @@ describe('FeedBackUtility Tests', () => {
160160

161161
it('should throw an error when endpoint is not defined', () => {
162162
recommendationsEvent.endpoint = undefined;
163-
expect(() => recommendationsEvent.getUrl()).toThrowError(
163+
expect(() => recommendationsEvent.getUrl()).toThrow(
164164
'Resource is not defined for the FeedBack Object.',
165165
);
166166
});
@@ -219,7 +219,7 @@ describe('FeedBackUtility Tests', () => {
219219
recommendationsEvent = setupRecommendationsEvent({
220220
method: 'post',
221221
});
222-
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError('Mocked API Error');
222+
await expect(sendRequest(recommendationsEvent)).rejects.toThrow('Mocked API Error');
223223
expect(client.post).toHaveBeenCalledWith(
224224
recommendationsEvent.getUrl(),
225225
recommendationsEvent.getData(),
@@ -232,7 +232,7 @@ describe('FeedBackUtility Tests', () => {
232232
method: 'put',
233233
eventId: uuidv4(),
234234
});
235-
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError('Mocked API Error');
235+
await expect(sendRequest(recommendationsEvent)).rejects.toThrow('Mocked API Error');
236236
expect(client.put).toHaveBeenCalledWith(
237237
recommendationsEvent.getUrl(),
238238
recommendationsEvent.getData(),
@@ -245,7 +245,7 @@ describe('FeedBackUtility Tests', () => {
245245
method: 'patch',
246246
eventId: uuidv4(),
247247
});
248-
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError('Mocked API Error');
248+
await expect(sendRequest(recommendationsEvent)).rejects.toThrow('Mocked API Error');
249249
expect(client.patch).toHaveBeenCalledWith(
250250
recommendationsEvent.getUrl(),
251251
recommendationsEvent.getData(),
@@ -257,7 +257,7 @@ describe('FeedBackUtility Tests', () => {
257257
method: 'delete',
258258
eventId: uuidv4(),
259259
});
260-
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError(
260+
await expect(sendRequest(recommendationsEvent)).rejects.toThrow(
261261
'Unsupported HTTP method: delete',
262262
);
263263
});
@@ -267,7 +267,7 @@ describe('FeedBackUtility Tests', () => {
267267
method: 'get',
268268
eventId: uuidv4(),
269269
});
270-
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError(
270+
await expect(sendRequest(recommendationsEvent)).rejects.toThrow(
271271
'Unsupported HTTP method: get',
272272
);
273273
});
@@ -295,7 +295,7 @@ describe('FeedBackUtility Tests', () => {
295295
dataOverride: null,
296296
override: true,
297297
}),
298-
).toThrowError('The data property cannot be null or undefined');
298+
).toThrow('The data property cannot be null or undefined');
299299
});
300300

301301
it('should throw an error when data is an array but method is not a POST', () => {
@@ -307,7 +307,7 @@ describe('FeedBackUtility Tests', () => {
307307
override: true,
308308
eventId: uuidv4(),
309309
}),
310-
).toThrowError("Array 'data' is only allowed for 'post' requests");
310+
).toThrow("Array 'data' is only allowed for 'post' requests");
311311
});
312312

313313
it('should throw an error when data is an empty array and method is a POST', () => {
@@ -318,7 +318,7 @@ describe('FeedBackUtility Tests', () => {
318318
dataOverride: [],
319319
override: true,
320320
}),
321-
).toThrowError("The 'data' array cannot be empty");
321+
).toThrow("The 'data' array cannot be empty");
322322
});
323323

324324
it('should throw an error when data is any of any type other than array or object', () => {
@@ -329,7 +329,7 @@ describe('FeedBackUtility Tests', () => {
329329
dataOverride: 'invalid data type',
330330
override: true,
331331
}),
332-
).toThrowError("The 'data' must be either a non-null object or an array of objects");
332+
).toThrow("The 'data' must be either a non-null object or an array of objects");
333333
});
334334

335335
it('should throw an error when submitted data has missing fields', () => {
@@ -340,7 +340,7 @@ describe('FeedBackUtility Tests', () => {
340340
dataOverride: {},
341341
override: true,
342342
}),
343-
).toThrowError(/The 'data' object is missing required property: \w+/);
343+
).toThrow(/The 'data' object is missing required property: \w+/);
344344
});
345345

346346
it('should throw an error when submitted data array has invalid data', () => {
@@ -351,7 +351,7 @@ describe('FeedBackUtility Tests', () => {
351351
dataOverride: [null],
352352
override: true,
353353
}),
354-
).toThrowError(/Item at position \w+ in 'data' is not a valid object/);
354+
).toThrow(/Item at position \w+ in 'data' is not a valid object/);
355355
});
356356

357357
it('should throw an error when submitted data array has valid data but with missing fields', () => {
@@ -362,12 +362,12 @@ describe('FeedBackUtility Tests', () => {
362362
dataOverride: [{}],
363363
override: true,
364364
}),
365-
).toThrowError(/Missing required property in 'data': \w+ at position: \w+/);
365+
).toThrow(/Missing required property in 'data': \w+ at position: \w+/);
366366
});
367367

368368
it('should throw an error when endpoint is not defined', () => {
369369
recommendationsInteractionEvent.endpoint = undefined;
370-
expect(() => recommendationsInteractionEvent.getUrl()).toThrowError(
370+
expect(() => recommendationsInteractionEvent.getUrl()).toThrow(
371371
'Resource is not defined for the FeedBack Object.',
372372
);
373373
});
@@ -440,7 +440,7 @@ describe('FeedBackUtility Tests', () => {
440440
recommendationsInteractionEvent = setupRecommendationsInteractionEvent({
441441
method: 'post',
442442
});
443-
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
443+
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
444444
'Mocked API Error',
445445
);
446446
expect(client.post).toHaveBeenCalledWith(
@@ -455,7 +455,7 @@ describe('FeedBackUtility Tests', () => {
455455
method: 'put',
456456
eventId: uuidv4(),
457457
});
458-
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
458+
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
459459
'Mocked API Error',
460460
);
461461
expect(client.put).toHaveBeenCalledWith(
@@ -470,7 +470,7 @@ describe('FeedBackUtility Tests', () => {
470470
method: 'patch',
471471
eventId: uuidv4(),
472472
});
473-
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
473+
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
474474
'Mocked API Error',
475475
);
476476
expect(client.patch).toHaveBeenCalledWith(
@@ -483,7 +483,7 @@ describe('FeedBackUtility Tests', () => {
483483
recommendationsInteractionEvent = setupRecommendationsInteractionEvent({
484484
method: 'delete',
485485
});
486-
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
486+
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
487487
'Unsupported HTTP method: delete',
488488
);
489489
});
@@ -493,7 +493,7 @@ describe('FeedBackUtility Tests', () => {
493493
method: 'get',
494494
id: uuidv4(),
495495
});
496-
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
496+
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
497497
'Unsupported HTTP method: get',
498498
);
499499
});

contentcuration/contentcuration/frontend/shared/utils/validation.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,10 @@ describe('channelEdit utils', () => {
353353
describe('isNodeComplete', () => {
354354
describe('for all kinds of nodes', () => {
355355
it('throws a reference error if node details are not defined', () => {
356-
expect(() => isNodeComplete({ nodeDetails: undefined })).toThrowError(
356+
expect(() => isNodeComplete({ nodeDetails: undefined })).toThrow(
357357
new ReferenceError('node details must be defined'),
358358
);
359-
expect(() => isNodeComplete({ nodeDetails: null })).toThrowError(
359+
expect(() => isNodeComplete({ nodeDetails: null })).toThrow(
360360
new ReferenceError('node details must be defined'),
361361
);
362362
});
@@ -417,10 +417,10 @@ describe('channelEdit utils', () => {
417417

418418
it('throws a reference error if assessment items are not defined', () => {
419419
const error = new ReferenceError('assessment items must be defined for exercises');
420-
expect(() => isNodeComplete({ nodeDetails, assessmentItems: undefined })).toThrowError(
420+
expect(() => isNodeComplete({ nodeDetails, assessmentItems: undefined })).toThrow(
421421
error,
422422
);
423-
expect(() => isNodeComplete({ nodeDetails, assessmentItems: null })).toThrowError(error);
423+
expect(() => isNodeComplete({ nodeDetails, assessmentItems: null })).toThrow(error);
424424
});
425425

426426
it('returns false if node details are not valid', () => {
@@ -528,8 +528,8 @@ describe('channelEdit utils', () => {
528528
const error = new ReferenceError(
529529
'files must be defined for a node other than topic or exercise',
530530
);
531-
expect(() => isNodeComplete({ nodeDetails, files: undefined })).toThrowError(error);
532-
expect(() => isNodeComplete({ nodeDetails, files: null })).toThrowError(error);
531+
expect(() => isNodeComplete({ nodeDetails, files: undefined })).toThrow(error);
532+
expect(() => isNodeComplete({ nodeDetails, files: null })).toThrow(error);
533533
});
534534

535535
it('returns false if node details are not valid', () => {

0 commit comments

Comments
 (0)