Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27,834 changes: 15,947 additions & 11,887 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"reason-react": "^0.8.0"
"reason-react": "^0.8.0",
"rescript": "^9.1.4"
},
"devDependencies": {
"@glennsl/bs-jest": "^0.7.0",
Expand Down
124 changes: 0 additions & 124 deletions src/Avenue/Actions_spec.re

This file was deleted.

116 changes: 116 additions & 0 deletions src/Avenue/Actions_spec.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
open Jest
open Expect

let game =
Game.load_setup(
Some(0),
"",
Grid.setup(Grid.map_A),
list{
(Road.of_int(0), Yellow),
(Road.of_int(1), Yellow),
(Road.of_int(2), Yellow),
(Road.of_int(3), Yellow),
},
list{A, B},
) |> Game.begin_game

let flip_farm_game = game |> Game.flip_farm

let flip_road_game = flip_farm_game |> Game.flip_road

let peek_farm_game = flip_road_game |> Game.peek_farm

let draw_road_game = peek_farm_game |> Game.draw_road(0, 0)

let flip_road2_game = draw_road_game |> Game.flip_road

let draw_road2_game = flip_road2_game |> Game.draw_road(0, 1)

let flip_road3_game = draw_road2_game |> Game.flip_road

let draw_road3_game = flip_road3_game |> Game.draw_road(0, 2)

let flip_road4_game = draw_road3_game |> Game.flip_road

let draw_road4_game = flip_road4_game |> Game.draw_road(0, 3)

let end_round_game = draw_road4_game |> Game.end_round

let ended_game = end_round_game |> Game.end_game

let allow_peek_game = {
...flip_road_game,
avenue: {
...flip_road_game.avenue,
farm_deck: list{B, C},
},
}

let poke_game = allow_peek_game |> Game.peek_farm

describe("Actions.flip_farm", () => {
test("should stage be round for top farm", () =>
expect(flip_farm_game.avenue.stage) |> toEqual(Stage.Round(A, Zero))
)

test("should farm deck be removed from top card", () =>
expect(flip_farm_game.avenue.farm_deck) |> toEqual(list{Farm.B})
)
})

describe("Actions.flip_road", () => {
test("should current card be the top card", () =>
expect(flip_road_game.avenue.current_card) |> toEqual(Some((Road.of_int(0), Road.Card.Yellow)))
)

test("should road deck be left with rest of deck", () =>
expect(flip_road_game.avenue.road_deck) |> toEqual(list{
(Road.of_int(1), Road.Card.Yellow),
(Road.of_int(2), Road.Card.Yellow),
(Road.of_int(3), Road.Card.Yellow),
})
)

test("should game turn be greater than player turn", () =>
expect(flip_road_game.avenue.turn) |> toBeGreaterThan(flip_road_game.me.turn)
)
})

describe("Actions.peek_farm", () => {
test("should not allow player to look ahead", () =>
expect(peek_farm_game.me.lookahead) |> toEqual(false)
)

test("should not skip player turn after trying to use peek", () =>
expect(peek_farm_game.me.turn) |> toBeLessThan(peek_farm_game.avenue.turn)
)

test("should allow player to look ahead", () => expect(poke_game.me.lookahead) |> toEqual(true))

test("should skip player turn after using", () =>
expect(poke_game.me.turn) |> toEqual(poke_game.avenue.turn)
)
})

describe("Actions.draw_road", () => {
test("should road be empty at 0, 0", () =>
expect(peek_farm_game.me.grid[0][0].road) |> toEqual(None)
)

test("should road be drawn at 0, 0", () =>
expect(draw_road_game.me.grid[0][0].road) |> toEqual(Some(Road.of_int(0)))
)
})

describe("Actions.end_round", () =>
test("should stage be end of round", () =>
expect(end_round_game.avenue.stage) |> toEqual(Stage.Flow(RoundEnd))
)
)

describe("Actions.end_game", () =>
test("should stage be end of game", () =>
expect(ended_game.avenue.stage) |> toEqual(Stage.Flow(End))
)
)
Loading