Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active June 30, 2024 14:32
Show Gist options
  • Save trikitrok/6811113bdab5dec9e0b0 to your computer and use it in GitHub Desktop.
Save trikitrok/6811113bdab5dec9e0b0 to your computer and use it in GitHub Desktop.
Conway's rules tests better names
describe("rules", function() {
describe("rule to go on living", function() {
it("does't go on living because of overpopulation", function() {
expect(rules.goesOnLivingWith(4)).toBe(false);
});
it("does't go on living because of underpopulation", function() {
expect(rules.goesOnLivingWith(1)).toBe(false);
});
it("goes on living", function() {
expect(rules.goesOnLivingWith(3)).toBe(true);
expect(rules.goesOnLivingWith(2)).toBe(true);
});
});
describe("rule to be created", function() {
it("has enough neighbors to be created", function () {
expect(rules.isCreatedWith(3)).toBe(true);
});
it("has not enough neighbors to be created", function () {
expect(rules.isCreatedWith(1)).toBe(false);
});
it("has too many neighbors to be created", function () {
expect(rules.isCreatedWith(4)).toBe(false);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment