3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
794 stars 194 forks source link

[Feat] - Update Jest Tests #670

Closed adithyaakrishna closed 1 year ago

adithyaakrishna commented 1 year ago

Description:

This PR Updates Jest Tests to make it more readable, concise and with a pinch of optimisation if necessary :)

codecov[bot] commented 1 year ago

Codecov Report

Merging #670 (32a1519) into master (65cc2f1) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #670   +/-   ##
=======================================
  Coverage   83.04%   83.04%           
=======================================
  Files         141      141           
  Lines       11445    11445           
  Branches     2106     2106           
=======================================
  Hits         9504     9504           
  Misses       1609     1609           
  Partials      332      332           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

adithyaakrishna commented 1 year ago

@dkoes I have updated the tests in this MR to make it more concise and easily understandable. I have also grouped tests using describe().

In some cases, instead of tests like,

        expect(color).toHaveProperty("r", 1);
        expect(color).toHaveProperty("g", 0);
        expect(color).toHaveProperty("b", 0);

I have used expect(color).toMatchObject({ r: 1, g: 0, b: 0 });

and expect(JSON.stringify(scaled)).toEqual(JSON.stringify({ r: 255, g: 0, b: 0, a: 1 })); to expect(scaled).toEqual(expect.objectContaining({ r: 255, g: 0, b: 0, a: 1 }));

These are some examples, but across the 4 files, I have made use of the above properties and also some more after referring https://jestjs.io/