From e5a161e91efe78489f24171cf2729f29fb1baccb Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Fri, 6 Dec 2024 09:28:25 -0300 Subject: [PATCH] fix: broken download tests Declaring `browserslist` in package.json exposed a bug in the download.js tests that wasn't causing failures before (but arguably, should): one can't use arrow functions to mock constructors because calling `new` on them doesn't work. See the NOTE under: https://jestjs.io/docs/es6-class-mocks#-module-factory-function-must-return-a-function --- src/data/redux/thunkActions/download.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/redux/thunkActions/download.test.js b/src/data/redux/thunkActions/download.test.js index c94e306a..ca6767b9 100644 --- a/src/data/redux/thunkActions/download.test.js +++ b/src/data/redux/thunkActions/download.test.js @@ -6,9 +6,9 @@ import { RequestKeys } from 'data/constants/requests'; import api from 'data/services/lms/api'; import * as download from './download'; -const mockBlobWriter = jest.fn().mockName('BlobWriter'); -const mockTextReader = jest.fn().mockName('TextReader'); -const mockBlobReader = jest.fn().mockName('BlobReader'); +const mockBlobWriter = jest.fn(); +const mockTextReader = jest.fn(); +const mockBlobReader = jest.fn(); const mockZipAdd = jest.fn(); const mockZipClose = jest.fn(); @@ -21,9 +21,9 @@ jest.mock('@zip.js/zip.js', () => { close: mockZipClose.mockImplementation(() => Promise.resolve(files)), files, })), - BlobWriter: () => mockBlobWriter, - TextReader: () => mockTextReader, - BlobReader: () => mockBlobReader, + BlobWriter: function _() { return mockBlobWriter; }, + TextReader: function _() { return mockTextReader; }, + BlobReader: function _() { return mockBlobReader; }, }; });