Function to fetch scorecard.cash exchange list
Function to score the responses based on some added scoring criteria
Function to make sure the sorted list is divisible by three
Test for all the functions
Details
- Reviewers
bytesofman Fabien - Group Reviewers
Restricted Project - Commits
- rABC4f973e6a97c2: [e.cash] Add functions to fetch exchanges and score and sort them
npm run test
see if all test pass
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- ecash-get-scores
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 24037 Build 47684: Build Diff Build 47683: arc lint + arc unit
Event Timeline
web/e.cash/data/__tests__/scores.test.js | ||
---|---|---|
59 | Inside describe('getScoreCardData', () => {, add a beforeEach block and include global.fetch = jest.fn(); in there add an afterEach block and include global.fetch.mockClear(); delete global.fetch; in there useful to avoid mistakes like below, which can be a massive headache to discover (say you add new unit tests later on, happen to mock fetch, in some totally different file. they all fail for reasons that don't make any sense in the logs because your last mock in this file didn't delete global.fetch even though the others did | |
104 | no delete global.fetch here still "works" but only bc no other files with unit tests using this mock. | |
web/e.cash/data/scores.js | ||
113 | scoringCriteria | |
117 | in general, best to avoid _ in variable names scoring_criteria should be scoringCriteria exceptions for constants, though JS convention there would be to also keep it all in block caps, e.g. SCORING_CRITERIA -- which, anyway, this isn't that kind of a constant | |
117 | This function is doing two things
Need to at least change the name of the function to calculateScoreAndSortExchanges ... this is kind of awkward though, there's not really a good reason why both of these things should happen in the same function. Complicates review and unit tests. You should probably split this up to be two functions, getScore and sortExchanges -- each with unit tests |
web/e.cash/data/__tests__/scores.test.js | ||
---|---|---|
46 ↗ | (On Diff #40789) |
web/e.cash/data/__tests__/scores.test.js | ||
---|---|---|
70 ↗ | (On Diff #40795) | Please also check with an array of soze > 3 (e.g 8) |