-
Notifications
You must be signed in to change notification settings - Fork 6
Refactor Xpi tests to use Jest mocks instead of Sinon #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hey, thanks for the patch. Looks like Circle CI isn't configured correctly. I am going to look into that because the test suite should be run in this PR. |
|
@aluccatan could you push again in this PR? Circle CI should run the test suite next time. |
|
Hi, thank you for looking into it! I fixed the linting errors in Do you want me to squash the commits into a single one with the message "Remove Sinon from Xpi tests (#2)" or would you prefer to make your own modifications when merging? |
Codecov Report
@@ Coverage Diff @@
## master #162 +/- ##
=======================================
Coverage 97.37% 97.37%
=======================================
Files 10 10
Lines 419 419
Branches 90 90
=======================================
Hits 408 408
Misses 11 11 Continue to review full report at Codecov.
|
no, it's OK for now, I'll review the PR soon. |
|
Welp. I removed a newline again then ran tests, linted, ran prettier on my branch (which passes fine locally!), ran tests again and finally committed, but the Circle CI build keeps failing. ᕕ( ᐛ )ᕗ Super sorry, I'm sure this must be annoying. |
it's fine |
This pull request aims to fix #2: "Remove sinon from xpi tests".
I've refactored the test suites of the
Xpiclass to use Jest's mocks (jest.fn()).Mocks
mockZipLibOpenis the equivalent ofopenStub.mockOpenReadStreamis the equivalent ofopenReadStreamStub.Methods tests
Tests suites that did not need refactoring:
getFile().checkPath().getFilesByExt().close().Refactored tests suites:
open().getFiles().getChunkAsBuffer().getFileAsStream().Notes
The refactored file is slightly longer. I thought of splitting the test suite into multiple test files (one file per method tested), but I kept the tests in the same file (
xpi.spec.ts) because it seems that it's a convention in the codebase to declare something (say,foo.ts) in one file and have its test in a single file adjacent to it (say,foo.spec.ts), in the same folder.I could add another commit or two if you want it split, for example, in the following structure:
- src - io - xpi - index.ts # Contains the declaration of the Xpi class - tests # One test file per method of the Xpi class - open.test.ts - getFiles.test.ts - getFile.test.ts - checkPath.test.ts - getChunkAsBuffer.test.ts - getFileAsStream.test.ts - getFilesByExt.test.ts - close.test.tsOr, you know, leave it as-is.