Sha256: 73b3479674e7a764e5199d18345f4c77cb5127c8aefa62cc471c049915764613

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

describe "FormController/PickerRow" do
  tests Formotion::FormController

  # By default, `tests` uses @controller.init
  # this isn't ideal for our case, so override.
  def controller
    row_settings = {
      title: "Picker",
      key: :picker,
      type: :picker,
      items: ["Ruby", "Motion"],
      value: "Motion"
    }
    @form ||= Formotion::Form.new(
      sections: [{
        rows:[row_settings]
    }])

    @controller ||= Formotion::FormController.alloc.initWithForm(@form)
  end

  def picker_row
    @form.sections.first.rows.first
  end

  def picker
    picker_row.object.picker
  end

  after do
    picker_row.text_field.resignFirstResponder
    wait 0.5 do
    end
  end

  it "should open a the picker when tapped" do
    notif = App.notification_center.observe UIKeyboardDidShowNotification do |notification|
      @did_show = true
    end

    picker.superview.should == nil
    tap("Picker")
    picker.superview.should.not == nil

    wait 0.5 do
      @did_show.should == true
    end
  end

  it "should change row value when picked" do
    tap("Picker")

    wait 0.5 do
      picker.selectRow(0, inComponent: 0, animated: true)
      picker_row.object.pickerView(picker, didSelectRow:0, inComponent:0)
      wait 0.5 do
        picker_row.value.should == "Ruby"
      end
    end
  end

  it "doesn't have a clear button" do
    tap("Picker")
    picker_row.text_field.subviews.map(&:class).should.not.include UIButton
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
formotion-1.8 spec/functional/picker_row_spec.rb
formotion-1.7 spec/functional/picker_row_spec.rb
formotion-1.6 spec/functional/picker_row_spec.rb
formotion-1.5.1 spec/functional/picker_row_spec.rb
formotion-1.5.0 spec/functional/picker_row_spec.rb
formotion-1.4.0 spec/functional/picker_row_spec.rb