Skip to content

Commit

Permalink
fix: broken download tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arbrandes committed Dec 6, 2024
1 parent 0bbb6a3 commit f60c085
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/data/redux/thunkActions/download.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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; },
};
});

Expand Down

0 comments on commit f60c085

Please sign in to comment.