summaryrefslogtreecommitdiff
path: root/src/simulation/actions.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/actions.test.js')
-rw-r--r--src/simulation/actions.test.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/simulation/actions.test.js b/src/simulation/actions.test.js
index 457015d..d039f8a 100644
--- a/src/simulation/actions.test.js
+++ b/src/simulation/actions.test.js
@@ -3,7 +3,11 @@
import { actions } from './actions.js';
-const [move_forward, move_backward, turn_left, ...rest] = actions;
+const [
+ move_forward, move_backward,
+ turn_left, turn_right,
+ ...rest
+] = actions;
test("move forward", () => {
@@ -84,3 +88,29 @@ test("turn_left", () => {
});
+test("turn_right", () => {
+ 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(turn_right.propose(n, [1])).toEqual([
+ { agent_changes: [{ agent_id: 0, flags: { orientation: 'e' } }] },
+ ]);
+ expect(turn_right.propose(s, [1])).toEqual([
+ { agent_changes: [{ agent_id: 0, flags: { orientation: 'w' } }] },
+ ]);
+ expect(turn_right.propose(e, [1])).toEqual([
+ { agent_changes: [{ agent_id: 0, flags: { orientation: 's' } }] },
+ ]);
+ expect(turn_right.propose(w, [1])).toEqual([
+ { agent_changes: [{ agent_id: 0, flags: { orientation: 'n' } }] },
+ ]);
+
+ expect(turn_right.propose(n, [0])).toEqual([]);
+ expect(turn_right.propose(s, [-1])).toEqual([]);
+ expect(turn_right.propose(e, [0])).toEqual([]);
+ expect(turn_right.propose(w, [-1])).toEqual([]);
+});
+
+