UNPKG

@tdurtschi/bug

Version:

Bug is a simulation that models a weevil walking around in an HTML canvas.

32 lines 1.45 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var plantFactory_1 = __importDefault(require("./plantFactory")); var victor_1 = __importDefault(require("victor")); var vectors_1 = require("../../util/vectors"); describe("PlantFactory", function () { it("Creates a tree", function () { var tree = new plantFactory_1.default(function () { return 0; }, 0).build(); expect(tree); }); it("Passes initial state", function () { var tree = new plantFactory_1.default(function () { return 0; }, 0).build({ pos: new victor_1.default(100, 100), }); expect(vectors_1.vectorEquals(tree.pos, new victor_1.default(100, 100))).toBeTruthy(); }); it("Applies the correct ID", function () { var idGenerator = function () { return 1337; }; var tree = new plantFactory_1.default(idGenerator, 0).build(); expect(tree.id).toEqual(1337); }); it("Defaults position to a pseudo-random X coord at Y=0", function () { var plantFactory = new plantFactory_1.default(function () { return 0; }, 100); var tree = plantFactory.build(); expect(tree.pos.y).toEqual(0); expect(tree.pos.x).not.toEqual(plantFactory.build().pos.x); }); }); //# sourceMappingURL=plantFactory.spec.js.map