Skip to content

Instantly share code, notes, and snippets.

@thehulke
Last active January 26, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehulke/04240df94503abaded58cf02b06e1d61 to your computer and use it in GitHub Desktop.
Save thehulke/04240df94503abaded58cf02b06e1d61 to your computer and use it in GitHub Desktop.
Testing MEDIUM
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)
const harry = {
gradesAvg: 90
}
export const verifyCandidate = candidate => candidate.gradesAvg >= 90
const result = verifyCandidate(harry)
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