Sha256: ff56394f662d0e97d7b1199266169d648d800571d809909604434af7c8f5888b

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module "Cartilage.Views.BarView"

  setup: ->
    @testView = new Cartilage.Views.BarView
      segments: new Cartilage.Collections.Segments([
        new Cartilage.Models.Segment({ maximum: 20  }),
        new Cartilage.Models.Segment({ maximum: 40  }),
        new Cartilage.Models.Segment({ maximum: 60  }),
        new Cartilage.Models.Segment({ maximum: 80  }),
        new Cartilage.Models.Segment({ maximum: 100 })
      ])
      value: 54

    @testView.prepare()

test "should calculate correct widths", 5, ->

  _.each(@testView.subviews, (subview) ->
    # treat 0.19999999999999996 as 0.20
    equal subview.width.toFixed(2), 0.20, "correct width"
  )

test "should calculate correct fillWidths", 5, ->

  equal @testView.subviews[0].fillWidth, 1,  "correct fillWidth"
  equal @testView.subviews[1].fillWidth, 1,  "correct fillWidth"
  equal @testView.subviews[2].fillWidth, 0.7,"correct fillWidth" # 70% (14/20)of 3rd segment
  equal @testView.subviews[3].fillWidth, 0,  "correct fillWidth"
  equal @testView.subviews[4].fillWidth, 0,  "correct fillWidth"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cartilage-0.1.2 test/framework/cartilage/views/bar_view_test.js.coffee
cartilage-0.1.1 test/framework/cartilage/views/bar_view_test.js.coffee