Skip to content

Instantly share code, notes, and snippets.

@marcelofarias
Last active November 17, 2016 02:31
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 marcelofarias/552fc8a2e3f606c3fd2154546fd4cb91 to your computer and use it in GitHub Desktop.
Save marcelofarias/552fc8a2e3f606c3fd2154546fd4cb91 to your computer and use it in GitHub Desktop.
Hobbit Test Suite
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