Skip to content

Instantly share code, notes, and snippets.

@mrailton
Created September 19, 2016 20:28
Show Gist options
  • Save mrailton/a60bb26644807471b4fe72efa1f1d312 to your computer and use it in GitHub Desktop.
Save mrailton/a60bb26644807471b4fe72efa1f1d312 to your computer and use it in GitHub Desktop.
whatCanIDrink
function whatCanIDrink(age) {
if (age < 0) {
return "Sorry. I can’t tell what drink because that age is incorrect!";
} else if (age < 14) {
return "Drink Toddy"
} else if (age < 18) {
return "Drink Coke"
}
}
describe("whatCanIDrink", function () {
it('should return an error if age is less than 0', function () {
expect(whatCanIDrink(-1)).toBe("Sorry. I can’t tell what drink because that age is incorrect!")
});
it('should return Drink Toddy! if age is 13', function () {
expect(whatCanIDrink(13)).toBe("Drink Toddy")
});
it('should return Drink Coke! if age is 17', function () {
expect(whatCanIDrink(17)).toBe("Drink Coke")
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment