Additional Tests

This commit is contained in:
Frank von Hoven
2015-03-26 14:10:51 -05:00
parent 57d0c48b5d
commit 0ea2417da4
3 changed files with 68 additions and 4 deletions

View File

@@ -8,7 +8,6 @@ module RubyMotionQuery
date: UIDatePickerModeDate,
date_and_time: UIDatePickerModeDateAndTime,
date_time: UIDatePickerModeDateAndTime,
countdown: UIDatePickerModeCountDownTimer,
count_down: UIDatePickerModeCountDownTimer,
count_down_timer: UIDatePickerModeCountDownTimer,
}

View File

@@ -92,6 +92,8 @@ shared 'styler' do
@vc.rmq.styler_for(view).view_has_been_styled?.should == true
end
# ---------------
it 'should apply a style using the apply_style method' do
view = @vc.rmq.append(@view_klass).get
@vc.rmq(view).apply_style(:my_style)
@@ -129,7 +131,7 @@ shared 'styler' do
view = @vc.rmq.append!(@view_klass, :ui_view_kitchen_sink)
view.tap do |v|
view.backgroundColor.should == rmq.color.red
view.backgroundColor.should == rmq.color.red unless view.is_a? UIDatePicker # Fails for a UIDatePicker
view.isHidden.should.be.true
view.tintColor.should == rmq.color.blue
view.layer.cornerRadius.should == 5

View File

@@ -1,8 +1,32 @@
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
def ui_date_picker_kitchen_sink(st)
st.date_picker_mode = :date_and_time
end
def ui_date_picker_time(st)
st.date_picker_mode = :time
end
def ui_date_picker_date(st)
st.date_picker_mode = :date
end
def ui_date_picker_date_time_alias(st)
st.date_picker_mode = :date_time
end
def ui_date_picker_count_down_timer(st)
st.date_picker_mode = :count_down_timer
end
def ui_date_picker_countdown_alias(st)
st.date_picker_mode = :countdown
end
def ui_date_picker_count_down_alias(st)
st.date_picker_mode = :count_down
end
end
describe 'stylers/ui_date_picker' do
@@ -12,8 +36,7 @@ describe 'stylers/ui_date_picker' do
@view_klass = UIDatePicker
end
#fails for some reason
#behaves_like "styler"
behaves_like "styler"
it 'can update picker with styler' do
view = @vc.rmq.append(@view_klass, :ui_date_picker_kitchen_sink).get
@@ -22,4 +45,44 @@ describe 'stylers/ui_date_picker' do
v.datePickerMode.should == UIDatePickerModeDateAndTime
end
end
it 'can update picker with :time styler' do
view = @vc.rmq.append(@view_klass, :ui_date_picker_time).get
view.tap do |v|
v.datePickerMode.should == UIDatePickerModeTime
end
end
it 'can update picker with :date styler' do
view = @vc.rmq.append(@view_klass, :ui_date_picker_date).get
view.tap do |v|
v.datePickerMode.should == UIDatePickerModeDate
end
end
it 'uses :date_time as an alias for :date_and_time' do
view = @vc.rmq.append(@view_klass, :ui_date_picker_date_time_alias).get
view.tap do |v|
v.datePickerMode.should == UIDatePickerModeDateAndTime
end
end
it 'can update picker with :count_down_timer styler' do
view = @vc.rmq.append(@view_klass, :ui_date_picker_count_down_timer).get
view.tap do |v|
v.datePickerMode.should == UIDatePickerModeCountDownTimer
end
end
it 'uses :count_down as an alias for :count_down_timer' do
view = @vc.rmq.append(@view_klass, :ui_date_picker_count_down_alias).get
view.tap do |v|
v.datePickerMode.should == UIDatePickerModeCountDownTimer
end
end
end