Sha256: 9935a2d188d410e849bfe8ac0232c371402e3e4024f27fe0a1c0b795d1c301b8

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

describe UnderOs::UI::Switch do
  before do
    @switch = UnderOs::UI::Switch.new
  end

  it "inherits fromthe UnderOs::UI::Input" do
    (UnderOs::UI::Switch < UnderOs::UI::Input).should == true
  end

  describe '#initialize' do
    it "should spawn new switchs" do
      @switch.class.should == UnderOs::UI::Switch
    end

    it "should wrap the UISwitch class" do
      @switch._.class.should == UISwitch
    end

    it "should assign correct tag name" do
      @switch.tagName.should == 'SWITCH'
    end

    it "should accept the 'value' option" do
      switch = UnderOs::UI::Switch.new(value: 'smth')
      switch.value.should == 'smth'
    end

    it "should accept the 'checked' option" do
      switch = UnderOs::UI::Switch.new(checked: true)
      switch.checked.should == true
    end
  end

  describe '#value' do
    it "should save the value correctly" do
      @switch.value = 'something'
      @switch.value.should == 'something'
    end
  end

  describe '#checked' do
    it "should allow to flip the switch on" do
      @switch.checked = true
      @switch._.on?.should == true
    end

    it "should allow to flip the switch off" do
      @switch.checked = false
      @switch._.on?.should == false
    end

    it "should return the state back correctly" do
      @switch.checked = true
      @switch.checked.should == true

      @switch.checked = false
      @switch.checked.should == false
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 spec/under_os/ui/switch_spec.rb
under-os-1.3.0 spec/lib/under_os/ui/switch_spec.rb
under-os-1.2.1 spec/lib/under_os/ui/switch_spec.rb
under-os-1.2.0 spec/lib/under_os/ui/switch_spec.rb