Sha256: 39ec907a59fab515fdfa231abee829a7ba3e285057daea9a457df3c1c12d4f02

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

class CountryInputTest < ActionView::TestCase
  test 'input generates a country select field' do
    with_input_for @user, :country, :country
    assert_select 'select#user_country'
    assert_select 'select option[value=BR]', 'Brazil'
    assert_no_select 'select option[value=""][disabled=disabled]'
  end

  test 'input generates a country select with SimpleForm default' do
    swap SimpleForm, country_priority: [ 'Brazil' ] do
      with_input_for @user, :country, :country
      assert_select 'select option[value="BR"] + option[value="---------------"][disabled=disabled]'
    end
  end

  test 'input generates a country select using options priority' do
    with_input_for @user, :country, :country, priority: [ 'Ukraine' ]
    assert_select 'select option[value="UA"] + option[value="---------------"][disabled=disabled]'
  end

  test 'input does generate select element with required html attribute' do
    with_input_for @user, :country, :country
    assert_select 'select.required'
    assert_select 'select[required]'
  end

  test 'input does generate select element with aria-required html attribute' do
    with_input_for @user, :country, :country
    assert_select 'select.required'
    assert_select 'select[aria-required]'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_form-5.2.0 test/inputs/country_input_test.rb