Files
screeps-scripts/test/unit/main.test.ts

38 lines
1.0 KiB
TypeScript

import { loop } from '../../src/main';
import { Game, Memory } from './mock';
import { assert } from 'chai';
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());
});
it('Automatically delete memory of missing creeps', () => {
Memory.creeps.persistValue = 'any value';
Memory.creeps.notPersistValue = 'any value';
Game.creeps.persistValue = 'any value';
loop();
assert.isDefined(Memory.creeps.persistValue);
assert.isUndefined(Memory.creeps.notPersistValue);
});
});