1 | import queueReducer from "./queue-reducer";
|
2 |
|
3 | describe("queueReducer", () => {
|
4 | it("should convert nextActions to queue", () => {
|
5 | const state = {
|
6 | game: {
|
7 | nextActions: [
|
8 | {
|
9 | action: { type: "TEST_ACTION" }
|
10 | }
|
11 | ]
|
12 | }
|
13 | };
|
14 | const after = queueReducer(state, { type: "TEST_ACTION_2" });
|
15 | expect(after.game.queue[0].type).toEqual("object");
|
16 | expect(after.game.queue[0].properties.type.enum[0]).toEqual("TEST_ACTION");
|
17 | });
|
18 |
|
19 | it("should accept/reject actions", () => {
|
20 | const state = {
|
21 | game: {
|
22 | queue: [
|
23 | {
|
24 | type: "object",
|
25 | properties: {
|
26 | type: {
|
27 | enum: ["TEST_ACTION"]
|
28 | }
|
29 | }
|
30 | }
|
31 | ]
|
32 | }
|
33 | };
|
34 | queueReducer(state, { type: "TEST_ACTION" });
|
35 | expect(() => {
|
36 | queueReducer(state, { type: "INVALID_ACTION" });
|
37 | }).toThrow();
|
38 | expect(() => {
|
39 | queueReducer(state, null);
|
40 | }).toThrow();
|
41 | });
|
42 | });
|