Sha256: a4729f14702369d1ad91f611bfacaed61aaa608c0e43c2b2e3a8aab95752471e

Contents?: true

Size: 1.41 KB

Versions: 12

Compression:

Stored size: 1.41 KB

Contents

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

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

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

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

  def picker
    date_row.object.picker
  end

  after do
    date_row.text_field.resignFirstResponder
    wait 1 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("Date")
    picker.superview.should.not == nil

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

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

    wait 1 do
      # RubyMotion has some memory crashes if you don't make this an ivar/retain it.
      @march_26 = 701568000
      new_date = NSDate.dateWithTimeIntervalSince1970(@march_26).retain
      picker.setDate(new_date, animated: true)
      wait 1 do
        picker.sendActionsForControlEvents(UIControlEventValueChanged)
        self.date_row.value.should == @march_26
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
formotion-1.3.1 spec/functional/date_row_spec.rb
formotion-1.3 spec/functional/date_row_spec.rb
formotion-1.2 spec/functional/date_row_spec.rb
formotion-1.1.5 spec/functional/date_row_spec.rb
formotion-1.1.4 spec/functional/date_row_spec.rb
formotion-1.1.3 spec/functional/date_row_spec.rb
formotion-1.1.2 spec/functional/date_row_spec.rb
formotion-1.1.1 spec/functional/date_row_spec.rb
formotion-1.1 spec/functional/date_row_spec.rb
formotion-1.0 spec/functional/date_row_spec.rb
formotion-0.5.1 spec/functional/date_row_spec.rb
formotion-0.5 spec/functional/date_row_spec.rb