Sha256: a1057e6eff669b6ffbb24537b940d42fc96f6f4ddc97e6d66e2bf225ab380c50

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 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

  it "doesn't have a clear button" do
    tap("Date")
    date_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/date_row_spec.rb
formotion-1.7 spec/functional/date_row_spec.rb
formotion-1.6 spec/functional/date_row_spec.rb
formotion-1.5.1 spec/functional/date_row_spec.rb
formotion-1.5.0 spec/functional/date_row_spec.rb
formotion-1.4.0 spec/functional/date_row_spec.rb