34 lines
1.1 KiB
Elixir
34 lines
1.1 KiB
Elixir
defmodule GameRegistryTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
@moduledoc """
|
|
This module includes tests for Amethyst.GameRegistry
|
|
"""
|
|
|
|
test "Register a game" do
|
|
Amethyst.GameRegistry.register(:fake_game, [:some_meta])
|
|
assert Amethyst.GameRegistry.list() |> Enum.member?({:fake_game, [:some_meta]})
|
|
end
|
|
|
|
test "Register many games" do
|
|
Range.new(0, 50) |> Enum.map(fn game ->
|
|
game = String.to_atom("game#{game}")
|
|
Amethyst.GameRegistry.register(game, [])
|
|
game
|
|
end) |> Enum.map(fn game ->
|
|
assert Amethyst.GameRegistry.list() |> Enum.member?({game, []})
|
|
end)
|
|
end
|
|
|
|
test "Register and get default game" do
|
|
Amethyst.GameRegistry.register(:fake_game, [default: true])
|
|
assert Amethyst.GameRegistry.get_default() == {:fake_game, [default: true]}
|
|
end
|
|
|
|
test "Fail to register multiple games" do
|
|
Amethyst.GameRegistry.register(:fake_game, [default: true])
|
|
assert Amethyst.GameRegistry.register(:other_game, [default: true]) == {:error, :default_exists}
|
|
assert Amethyst.GameRegistry.get_default() == {:fake_game, [default: true]}
|
|
end
|
|
end
|