require "test_helper"

class SuggestedMeaningTest < ActiveSupport::TestCase
  test "should be valid with all attributes" do
    meaning = SuggestedMeaning.new(
      entry: entries(:one),
      language_code: supported_languages(:one).code,
      alternative_translation: "New Translation",
      submitted_by: users(:one)
    )
    assert meaning.valid?
  end

  test "should be invalid without a language_code" do
    meaning = SuggestedMeaning.new(
      entry: entries(:one),
      alternative_translation: "New Translation",
      submitted_by: users(:one)
    )
    assert_not meaning.valid?
  end

  test "should be invalid without an alternative_translation" do
    meaning = SuggestedMeaning.new(
      entry: entries(:one),
      language_code: supported_languages(:one).code,
      submitted_by: users(:one)
    )
    assert_not meaning.valid?
  end

  test "should have a default status of pending" do
    meaning = SuggestedMeaning.new(
      entry: entries(:one),
      language_code: supported_languages(:one).code,
      alternative_translation: "New Translation",
      submitted_by: users(:one)
    )
    assert meaning.pending?
  end

  test "can be accepted" do
    meaning = SuggestedMeaning.new(
      entry: entries(:one),
      language_code: supported_languages(:one).code,
      alternative_translation: "New Translation",
      submitted_by: users(:one),
      status: :accepted
    )
    assert meaning.accepted?
  end

  test "can be rejected" do
    meaning = SuggestedMeaning.new(
      entry: entries(:one),
      language_code: supported_languages(:one).code,
      alternative_translation: "New Translation",
      submitted_by: users(:one),
      status: :rejected
    )
    assert meaning.rejected?
  end
end
