test('Grid.View.legacyMasteryDetails', () => { const outcome = {mastery_points: 5} ok( isEqual(Grid.View.legacyMasteryDetails(8, outcome), ['rating_0', '#127A1B', 'Exceeds Mastery']), 'returns "exceeds" if 150% or more of mastery score' ) ok( isEqual(Grid.View.legacyMasteryDetails(5, outcome), ['rating_1', '#00AC18', 'Meets Mastery']), 'returns "mastery" if equal to mastery score' ) ok( isEqual(Grid.View.legacyMasteryDetails(7, outcome), ['rating_1', '#00AC18', 'Meets Mastery']), 'returns "mastery" if above mastery score' ) ok( isEqual(Grid.View.legacyMasteryDetails(3, outcome), ['rating_2', '#FC5E13', 'Near Mastery']), 'returns "near-mastery" if half of mastery score or greater' ) ok( isEqual(Grid.View.legacyMasteryDetails(1, outcome), [ 'rating_3', '#EE0612', 'Well Below Mastery' ]), 'returns "remedial" if less than half of mastery score' ) })
test('Grid.View.masteryDetails with scaling (points_possible 0)', () => { const outcome = {mastery_points: 5, points_possible: 0} Grid.ratings = [ {points: 10, color: '00ff00', description: 'great'}, {points: 5, color: '0000ff', description: 'OK'}, {points: 0, color: 'ff0000', description: 'turrable'} ] ok( isEqual(Grid.View.masteryDetails(5, outcome), ['rating_0', '#00ff00', 'great']), 'returns color of first rating' ) ok( isEqual(Grid.View.masteryDetails(2.5, outcome), ['rating_1', '#0000ff', 'OK']), 'returns color of second rating' ) ok( isEqual(Grid.View.masteryDetails(0, outcome), ['rating_2', '#ff0000', 'turrable']), 'returns color of third rating' ) })
test('Grid.View.masteryDetails', () => { const outcome = {mastery_points: 5, points_possible: 10} const spy = sinon.spy(Grid.View, 'legacyMasteryDetails') Grid.View.masteryDetails(10, outcome) ok(spy.calledOnce, 'calls legacyMasteryDetails when no custom ratings defined') Grid.ratings = [ {points: 10, color: '00ff00', description: 'great'}, {points: 5, color: '0000ff', description: 'OK'}, {points: 0, color: 'ff0000', description: 'turrable'} ] ok( isEqual(Grid.View.masteryDetails(10, outcome), ['rating_0', '#00ff00', 'great']), 'returns color of first rating' ) ok( isEqual(Grid.View.masteryDetails(9, outcome), ['rating_1', '#0000ff', 'OK']), 'returns color of second rating' ) ok( isEqual(Grid.View.masteryDetails(5, outcome), ['rating_1', '#0000ff', 'OK']), 'returns color of second rating' ) ok( isEqual(Grid.View.masteryDetails(4, outcome), ['rating_2', '#ff0000', 'turrable']), 'returns color of third rating' ) ok( isEqual(Grid.View.masteryDetails(0, outcome), ['rating_2', '#ff0000', 'turrable']), 'returns color of third rating' ) })