@tdurtschi/bug
Version:
Bug is a simulation that models a weevil walking around in an HTML canvas.
38 lines • 1.68 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var bugFactory_1 = __importDefault(require("./bugFactory"));
var Victor = require("victor");
var vectors_1 = require("../../util/vectors");
describe("BugFactory", function () {
it("Creates a bug", function () {
var bug = new bugFactory_1.default(function () { return 0; }, 0).build();
expect(bug);
});
it("Passes initial state", function () {
var bug = new bugFactory_1.default(function () { return 0; }, 0).build({
pos: new Victor(100, 100),
});
vectors_1.expectEquals(bug.pos, new Victor(100, 100));
});
it("Applies the correct ID", function () {
var idGenerator = function () { return 1337; };
var bug = new bugFactory_1.default(idGenerator, 0).build();
expect(bug.id).toEqual(1337);
});
it("Defaults position to a pseudo-random X coord at Y=0", function () {
var bugFactory = new bugFactory_1.default(function () { return 0; }, 100);
var bug = bugFactory.build();
expect(bug.pos.y).toEqual(0);
expect(bug.pos.x).not.toEqual(bugFactory.build().pos.x);
});
it("Optionally, takes a numerical size and converts it to a vector", function () {
var bugFactory = new bugFactory_1.default(function () { return 0; }, 0);
var bug = bugFactory.build({ size: 10 });
expect(bug.size.y).not.toBeUndefined();
expect(bug.size.x).not.toBeUndefined();
});
});
//# sourceMappingURL=bugFactory.spec.js.map