amethyst/apps/amethyst/test/game_registry_test.exs
Kodi Craft 450ca4d53a
Some checks failed
Build & Test / nix-build (push) Failing after 41s
Implement tests for GameRegistry
2024-08-19 00:00:03 +02:00

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