import { describe, when, then, it } from "../src/grebe";
import { expect, should } from "chai";
import * as sinon from "sinon";
should();
import { Bird } from "./bird";
describe("Bird", () => {
var clock = sinon.useFakeTimers();
var sut = new Bird();
it("has 2 legs", () => {
sut.numLegs.should.equal(2);
});
it("has 2 wings", () => {
sut.numWings.should.equal(2);
});
it("starts on ground", () => {
sut.isFlying.should.be.false;
});
when("flapping wings", () => {
sut.flap();
it("is not yet flying", () => {
sut.isFlying.should.be.false;
});
when("1s passes", () => {
clock.tick(1000);
it("is flying", () => {
sut.isFlying.should.be.true;
});
when("it hits a tree", () => {
sut.hitTree();
it("is not flying", () => {
sut.isFlying.should.be.false;
});
it("loses wings", () => {
sut.numWings.should.equal(0);
})
it("cannot fly again", () => {
expect(() => sut.flap()).to.throw("Wings are broken, cannot fly");
});
});
});
});
clock.restore();
});