Created
September 29, 2021 21:47
-
-
Save frogbandit/8216cd18fec03d41ac69e3509abb6d32 to your computer and use it in GitHub Desktop.
Nova Credit Income Model Reconcile Confidence Scores Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { assert } from 'chai'; | |
import reconcileConfidenceScores from '../src/reconcileConfidenceScores'; | |
describe('reconcileConfidenceScores', () => { | |
it('filters out entries with empty confidence score inputs', () => { | |
const result = reconcileConfidenceScores([ | |
{ | |
score_conventional: 0, | |
score_non_conventional: 0, | |
score_non_wage: 0, | |
}, | |
]); | |
assert.deepEqual(result, []); | |
}); | |
it('can both filter/pass and map/round multiple entries', () => { | |
const confidenceScores = [ | |
{ id: 1, score_conventional: 0, score_non_conventional: 0, score_non_wage: 0 }, | |
{ id: 2, score_conventional: 10, score_non_conventional: 10, score_non_wage: 0 }, | |
{ id: 3, score_conventional: 0, score_non_conventional: 0, score_non_wage: 1 }, | |
{ id: 4, score_conventional: 0, score_non_conventional: 10.1, score_non_wage: 0 }, | |
{ id: 5, score_conventional: 10.9, score_non_conventional: 0, score_non_wage: 0 }, | |
{ id: 6, score_conventional: 9, score_non_conventional: 9, score_non_wage: 0 }, | |
{ id: 7, score_conventional: 5, score_non_conventional: 65, score_non_wage: 50 }, | |
]; | |
const result = reconcileConfidenceScores(confidenceScores); | |
const expected = [ | |
{ ...confidenceScores[2], confidence_score: 1 }, // id: 3 | |
{ ...confidenceScores[3], confidence_score: 10 }, // id: 4 | |
{ ...confidenceScores[4], confidence_score: 11 }, // id: 5 | |
{ ...confidenceScores[6], confidence_score: 65 }, // id: 7 | |
]; | |
assert.deepEqual(result, expected); | |
}); | |
... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment