Skip to content

Commit 26e1bdf

Browse files
authoredAug 8, 2021
Unit test for: Automatically delete memory of missing creeps (screepers#158)
1 parent a872ae9 commit 26e1bdf

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed
 

‎test/unit/main.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,16 @@ describe("main", () => {
2222
it("should return void when called with no context", () => {
2323
assert.isUndefined(loop());
2424
});
25+
26+
it("Automatically delete memory of missing creeps", () => {
27+
Memory.creeps.persistValue = "any value";
28+
Memory.creeps.notPersistValue = "any value";
29+
30+
Game.creeps.persistValue = "any value";
31+
32+
loop();
33+
34+
assert.isDefined(Memory.creeps.persistValue);
35+
assert.isUndefined(Memory.creeps.notPersistValue);
36+
});
2537
});

‎test/unit/mock.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
export const Game = {
2-
creeps: [],
1+
export const Game: {
2+
creeps: { [name: string]: any };
3+
rooms: any;
4+
spawns: any;
5+
time: any;
6+
} = {
7+
creeps: {},
38
rooms: [],
49
spawns: {},
510
time: 12345
611
};
712

8-
export const Memory = {
9-
creeps: []
13+
export const Memory: {
14+
creeps: { [name: string]: any };
15+
} = {
16+
creeps: {}
1017
};

0 commit comments

Comments
 (0)
Please sign in to comment.