Skip to content

Instantly share code, notes, and snippets.

@stevgouws
Created September 10, 2019 08:38
Show Gist options
  • Save stevgouws/4b758e7fe3af59d5eb618b427c48a05a to your computer and use it in GitHub Desktop.
Save stevgouws/4b758e7fe3af59d5eb618b427c48a05a to your computer and use it in GitHub Desktop.
Boundary Analysis and Equivalence Class Testing Example
function isMinor(age) {
return age >= 0 && age < 18
}
describe("isMinor", () => {
it("should return true for any value between 0 and 18", () => {
expect(isMinor(10)).toEqual(true);
});
it("should return true for 0", () => {
expect(isMinor(0)).toEqual(true);
});
it("should return false for anything less than 0", () => {
expect(isMinor(-1).toEqual(false);
});
it("should return true for 17", () => {
expect(isMinor(17)).toEqual(true);
});
it("should return false for anything above 17", () => {
expect(isMinor(18)).toEqual(false);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment