1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
'use strict';
import { actions } from './actions.js';
const [move_forward, ...rest] = actions;
test("move forward", () => {
const n = { id: 0, x: 0, y: 0, flags: { orientation: 'n' } };
const s = { id: 0, x: 0, y: 0, flags: { orientation: 's' } };
const e = { id: 0, x: 0, y: 0, flags: { orientation: 'e' } };
const w = { id: 0, x: 0, y: 0, flags: { orientation: 'w' } };
expect(move_forward.propose(n, [1])).toEqual([
{ agent_changes: [{ agent_id: 0, x: 0, y: -1 }] },
]);
expect(move_forward.propose(s, [1])).toEqual([
{ agent_changes: [{ agent_id: 0, x: 0, y: 1 }] },
]);
expect(move_forward.propose(e, [1])).toEqual([
{ agent_changes: [{ agent_id: 0, x: 1, y: 0 }] },
]);
expect(move_forward.propose(w, [1])).toEqual([
{ agent_changes: [{ agent_id: 0, x: -1, y: 0 }] },
]);
expect(move_forward.propose(n, [0])).toEqual([]);
expect(move_forward.propose(s, [-1])).toEqual([]);
expect(move_forward.propose(e, [0])).toEqual([]);
expect(move_forward.propose(w, [-1])).toEqual([]);
});
|