add integration testing support

This commit is contained in:
kaen
2018-11-10 15:49:43 -08:00
parent 1bf84c2443
commit f8507b632a
10 changed files with 219 additions and 4 deletions

25
test/unit/main.test.ts Normal file
View File

@@ -0,0 +1,25 @@
import {assert} from "chai";
import {loop} from "../../src/main";
import {Game, Memory} from "./mock"
describe("main", () => {
before(() => {
// runs before all test in this block
});
beforeEach(() => {
// runs before each test in this block
// @ts-ignore : allow adding Game to global
global.Game = _.clone(Game);
// @ts-ignore : allow adding Memory to global
global.Memory = _.clone(Memory);
});
it("should export a loop function", () => {
assert.isTrue(typeof loop === "function");
});
it("should return void when called with no context", () => {
assert.isUndefined(loop());
});
});

10
test/unit/mock.ts Normal file
View File

@@ -0,0 +1,10 @@
export const Game = {
creeps: [],
rooms: [],
spawns: {},
time: 12345
};
export const Memory = {
creeps: []
};