Last active
January 26, 2019 19:16
-
-
Save thehulke/04240df94503abaded58cf02b06e1d61 to your computer and use it in GitHub Desktop.
Testing MEDIUM
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
const harry = [ | |
{ | |
name: 'Math', | |
grade: 95 | |
}, | |
{ | |
name: 'Good Magic', | |
grade: 100 | |
}, | |
{ | |
name: 'Bad Magic', | |
grade: 100 | |
} | |
] | |
export const verifyByClass = (className, grade, grades) => | |
grades.find(givenClass => givenClass.name === className).grade >= grade | |
export const calculateAvg = candidate => { | |
const sum = candidate.reduce( | |
(accumulatedGrades, currentClass) => accumulatedGrades + currentClass.grade, | |
0 | |
) | |
return sum / candidate.length | |
} | |
export const verifyCandidate = candidate => | |
calculateAvg(candidate) >= 90 && verifyByClass('Math', 95, candidate) | |
const result = verifyCandidate(harry) |
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
const harry = { | |
gradesAvg: 90 | |
} | |
export const verifyCandidate = candidate => candidate.gradesAvg >= 90 | |
const result = verifyCandidate(harry) |
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 {verifyCandidate} from './firstCase' | |
describe('University evaluation flow', ()=> { | |
test('verifyCandidate', ()=> { | |
const student = { | |
gradesAvg: 80 | |
} | |
expect(verifyCandidate(student)).toBeFalsy() | |
stundent.gradesAvg = 90 | |
expect(verifyCandidate(student)).toBeTruthy() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment