defmodule Outlook.TranslatorsTest do
  use Outlook.DataCase

  alias Outlook.Translators

  describe "deepl_accounts" do
    alias Outlook.Translators.DeeplAccount

    import Outlook.TranslatorsFixtures

    @invalid_attrs %{auth_key: nil, character_count: nil, character_limit: nil, description: nil, name: nil, our_character_count: nil}

    test "list_deepl_accounts/0 returns all deepl_accounts" do
      deepl_account = deepl_account_fixture()
      assert Translators.list_deepl_accounts() == [deepl_account]
    end

    test "get_deepl_account!/1 returns the deepl_account with given id" do
      deepl_account = deepl_account_fixture()
      assert Translators.get_deepl_account!(deepl_account.id) == deepl_account
    end

    test "create_deepl_account/1 with valid data creates a deepl_account" do
      valid_attrs = %{auth_key: "some auth_key", character_count: 42, character_limit: 42, description: "some description", name: "some name", our_character_count: 42}

      assert {:ok, %DeeplAccount{} = deepl_account} = Translators.create_deepl_account(valid_attrs)
      assert deepl_account.auth_key == "some auth_key"
      assert deepl_account.character_count == 42
      assert deepl_account.character_limit == 42
      assert deepl_account.description == "some description"
      assert deepl_account.name == "some name"
      assert deepl_account.our_character_count == 42
    end

    test "create_deepl_account/1 with invalid data returns error changeset" do
      assert {:error, %Ecto.Changeset{}} = Translators.create_deepl_account(@invalid_attrs)
    end

    test "update_deepl_account/2 with valid data updates the deepl_account" do
      deepl_account = deepl_account_fixture()
      update_attrs = %{auth_key: "some updated auth_key", character_count: 43, character_limit: 43, description: "some updated description", name: "some updated name", our_character_count: 43}

      assert {:ok, %DeeplAccount{} = deepl_account} = Translators.update_deepl_account(deepl_account, update_attrs)
      assert deepl_account.auth_key == "some updated auth_key"
      assert deepl_account.character_count == 43
      assert deepl_account.character_limit == 43
      assert deepl_account.description == "some updated description"
      assert deepl_account.name == "some updated name"
      assert deepl_account.our_character_count == 43
    end

    test "update_deepl_account/2 with invalid data returns error changeset" do
      deepl_account = deepl_account_fixture()
      assert {:error, %Ecto.Changeset{}} = Translators.update_deepl_account(deepl_account, @invalid_attrs)
      assert deepl_account == Translators.get_deepl_account!(deepl_account.id)
    end

    test "delete_deepl_account/1 deletes the deepl_account" do
      deepl_account = deepl_account_fixture()
      assert {:ok, %DeeplAccount{}} = Translators.delete_deepl_account(deepl_account)
      assert_raise Ecto.NoResultsError, fn -> Translators.get_deepl_account!(deepl_account.id) end
    end

    test "change_deepl_account/1 returns a deepl_account changeset" do
      deepl_account = deepl_account_fixture()
      assert %Ecto.Changeset{} = Translators.change_deepl_account(deepl_account)
    end
  end
end
