Last active
November 17, 2016 02:31
-
-
Save marcelofarias/552fc8a2e3f606c3fd2154546fd4cb91 to your computer and use it in GitHub Desktop.
Hobbit Test Suite
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
describe('Hobbit', function () { | |
var mordor, hobbit; | |
beforeAll(function () { | |
mordor = new Mordor(); // same instance for all specs | |
}); | |
beforeEach(function () { | |
hobbit = new Hobbit(); // new instance for each spec | |
}); | |
afterEach(function () { | |
hobbit.destroy(); | |
}); | |
afterAll(function () { | |
mordor.destroy(Ring.instance); // Mordor idiosyncrasy: destroy requires a ring. Ring.instance is a singleton | |
}); | |
it('wakes up hungry', function () { | |
expect(hobbit.isHungry()).toBe(true); | |
}); | |
it('is satisfied with lembas', function () { | |
expect(hobbit.isHungry()).toBe(true); | |
hobbit.eat(new Lembas()); | |
expect(hobbit.isHungry()).toBe(false); | |
}) | |
it('walks into Mordor when fed', function () { | |
hobbit.eat(new Lembas()); | |
expect(hobbit.walkInto(mordor)).toBe(true); // good old Mordor | |
}); | |
it('does not walk into Mordor when hungry', function () { | |
expect(hobbit.walkInto(mordor)).toBe(false); // good old Mordor | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment