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 336c602 commit 730e7c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/data/redux/thunkActions/download.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; },

Check warning on line 24 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (18.15)

Unexpected unnamed method 'BlobWriter'

Check failure on line 24 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (18.15)

Expected method shorthand

Check warning on line 24 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (20)

Unexpected unnamed method 'BlobWriter'

Check failure on line 24 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (20)

Expected method shorthand
TextReader: function () { return mockTextReader; },

Check warning on line 25 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (18.15)

Unexpected unnamed method 'TextReader'

Check failure on line 25 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (18.15)

Expected method shorthand

Check warning on line 25 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (20)

Unexpected unnamed method 'TextReader'

Check failure on line 25 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (20)

Expected method shorthand
BlobReader: function () { return mockBlobReader; },

Check warning on line 26 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (18.15)

Unexpected unnamed method 'BlobReader'

Check failure on line 26 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (18.15)

Expected method shorthand

Check warning on line 26 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (20)

Unexpected unnamed method 'BlobReader'

Check failure on line 26 in src/data/redux/thunkActions/download.test.js

View workflow job for this annotation

GitHub Actions / tests (20)

Expected method shorthand
};
});

Expand Down

0 comments on commit 730e7c3

Please sign in to comment.