Sha256: 5b82629bf67ee9d05878ef1d3fa8fce0c853c8f6c241147d0597f8320b62182d

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

describe UnderOs::UI::Commons do
  before do
    @view = UnderOs::UI::View.new
  end

  describe '#id' do
    it "should allow build views with ids" do
      view = UnderOs::UI::View.new(id: 'my-id')
      view.id.should == 'my-id'
    end

    it "should allow to change the id" do
      view = UnderOs::UI::View.new(id: 'old-id')
      view.id = 'new-id'
      view.id.should == 'new-id'
    end
  end

  describe '#data' do
    it "should allow to specify the data hash with views constructor" do
      view = UnderOs::UI::View.new(data: {my: 'data'})
      view.data.should == {my: 'data'}
    end

    it "should allow to assign the new data" do
      view = UnderOs::UI::View.new(data: {old: 'data'})
      view.data = {new: 'data'}
      view.data.should == {new: 'data'}
    end
  end

  describe '#hidden' do
    it "shoudl return 'false' for visible views" do
      @view.hidden.should == false
    end

    it "should return 'true' for hidden views" do
      @view._.hidden = true
      @view.hidden.should == true
    end
  end

  describe '#visible' do
    it "should return 'true' if the element's visible" do
      @view.visible.should == true
    end

    it "should return 'false' if the element's is hidden" do
      @view._.hidden = true
      @view.visible.should == false
    end
  end

  describe '#hide' do
    it "should hide elmements" do
      @view.hide
      @view.hidden.should == true
    end
  end

  describe '#show' do
    it "should show hidden elements" do
      @view.hide
      @view.show
      @view.visible.should == true
    end
  end

  describe '#toggle' do
    it "should show an element if it's hidden" do
      @view.hide
      @view.toggle
      @view.visible.should == true
    end

    it "should hide visible elements" do
      @view.toggle
      @view.hidden.should == true
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 spec/under_os/ui/utils/commons_spec.rb
under-os-1.3.0 spec/lib/under_os/ui/utils/commons_spec.rb
under-os-1.2.1 spec/lib/under_os/ui/utils/commons_spec.rb
under-os-1.2.0 spec/lib/under_os/ui/utils/commons_spec.rb
under-os-1.1.0 spec/lib/under_os/ui/utils/commons_spec.rb
under-os-1.0.0 spec/lib/under_os/ui/utils/commons_spec.rb