thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
385 stars 48 forks source link

Clean up OneByte tests #151

Closed EvanHahn closed 1 year ago

EvanHahn commented 1 year ago

This test-only change:

EvanHahn commented 1 year ago

These may already be tested in co2.test.js, so this may be a bad PR.

fershad commented 1 year ago

@EvanHahn thanks for this. It would actually be nice to reduce the number of tests in the co2.test.js file, so happy to explore moving more to the OneByte & Sustainable Web Design tests into their own files.

Using toBeCloseTo() looks good, and will definitely make our test cases more flexible as grid intensity data changes.

Do you want to use the PR to add more tests to the 1byte.test.js file. We can tackle the OneByte tests first, and then get on to the Sustainable Web Design tests in another PR.

EvanHahn commented 1 year ago

It would actually be nice to reduce the number of tests in the co2.test.js file, so happy to explore moving more to the OneByte & Sustainable Web Design tests into their own files.

I removed two redundant tests from co2.test.js in 0e6b4811e24cfa49cd29da90ebf894ca8111b649.

Do you want to use the PR to add more tests to the 1byte.test.js file. We can tackle the OneByte tests first, and then get on to the Sustainable Web Design tests in another PR.

It looks like the OneByte class is fully tested by this PR. What other tests would you like to see?

Again, feel free to message me on the CAT Slack or email me@evanhahn.com.

fershad commented 1 year ago

@EvanHahn thank you for this, looks good to me.