summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/epoch/tests/unit/core/d3.coffee
blob: 1b65c552a1a7de240f9470bb78eb808086524842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
describe 'd3.selection', ->
  [width, height] = [345, 543, null]
  [element, id] = [null, 'd3-element']

  before (done) ->
    element = doc.createElement('DIV')
    element.id = id
    doc.body.appendChild(element)
    d3.select('#' + id).style
      'width': width + "px"
      'height': height + "px"
    done()

  describe 'width', ->
    it 'should return the width of an element', ->
      assert.equal d3.select('#' + id).width(), width

    it 'should set the width of an element given a number', ->
      widthNumber = 50
      d3.select('#'+id).width(widthNumber)
      assert.equal d3.select('#'+id).width(), widthNumber

    it 'should set the width of an element given a css pixel length', ->
      widthString = '500px'
      d3.select('#'+id).width(widthString)
      assert.equal d3.select('#'+id).width(), +widthString.replace('px', '')

  describe 'height', ->
    it 'should return the height of an element', ->
      assert.equal d3.select('#' + id).height(), height

    it 'should set the height of an element given a number', ->
      heightNumber = 75
      d3.select('#'+id).height(heightNumber)
      assert.equal d3.select('#'+id).height(), heightNumber

    it 'should set the height of an element given a css pixel length', ->
      heightString = '343px'
      d3.select('#'+id).height(heightString)
      assert.equal d3.select('#'+id).height(), +heightString.replace('px', '')