BIG WIP of refactoring my work in TS
This commit is contained in:
parent
af5d2a5a97
commit
fbfc208129
12 changed files with 274 additions and 11 deletions
39
back/tests/WorldTest.ts
Normal file
39
back/tests/WorldTest.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import "jasmine";
|
||||
import {Message} from "../src/Model/Websocket/Message";
|
||||
import {World} from "../src/Model/World";
|
||||
import {MessageUserPosition, Point} from "../src/Model/Websocket/MessageUserPosition";
|
||||
|
||||
describe("World", () => {
|
||||
it("should connect user1 and user2", () => {
|
||||
let connectCalled: boolean = false;
|
||||
let connect = (user1: string, user2: string): void => {
|
||||
connectCalled = true;
|
||||
}
|
||||
let disconnect = (user1: string, user2: string): void => {
|
||||
|
||||
}
|
||||
|
||||
let world = new World(connect, disconnect);
|
||||
|
||||
world.join(new MessageUserPosition({
|
||||
userId: "foo",
|
||||
roomId: 1,
|
||||
position: new Point(100, 100)
|
||||
}));
|
||||
|
||||
world.join(new MessageUserPosition({
|
||||
userId: "bar",
|
||||
roomId: 1,
|
||||
position: new Point(500, 100)
|
||||
}));
|
||||
|
||||
world.updatePosition(new MessageUserPosition({
|
||||
userId: "bar",
|
||||
roomId: 1,
|
||||
position: new Point(101, 100)
|
||||
}));
|
||||
|
||||
expect(connectCalled).toBe(true);
|
||||
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue