Skip to content

Conversation

@HilaryDev
Copy link

This pull request aims to fix #2: "Remove sinon from xpi tests".

I've refactored the test suites of the Xpi class to use Jest's mocks (jest.fn()).


Mocks

  • mockZipLibOpen is the equivalent of openStub.
  • mockOpenReadStream is the equivalent of openReadStreamStub.

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.ts

Or, you know, leave it as-is.

@willdurand
Copy link
Member

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.

@willdurand
Copy link
Member

@aluccatan could you push again in this PR? Circle CI should run the test suite next time.

@HilaryDev
Copy link
Author

HilaryDev commented Jun 12, 2021

Hi, thank you for looking into it!

I fixed the linting errors in xpi.spec.ts (caused by the "remove whitespace" commit, which is funny).

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
Copy link

codecov bot commented Jun 12, 2021

Codecov Report

Merging #162 (69275ac) into master (061d5b1) will not change coverage.
The diff coverage is n/a.

❗ Current head 69275ac differs from pull request most recent head 35dea65. Consider uploading reports for the commit 35dea65 to get more accurate results
Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 061d5b1...35dea65. Read the comment docs.

@willdurand
Copy link
Member

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?

no, it's OK for now, I'll review the PR soon.

@HilaryDev
Copy link
Author

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.

@willdurand
Copy link
Member

Super sorry, I'm sure this must be annoying.

it's fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove sinon from xpi tests

2 participants