Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | describe 'Morris.Donut', -> |
| 2 | |||
| 3 | describe 'svg structure', -> |
||
| 4 | defaults = |
||
| 5 | element: 'graph' |
||
| 6 | data: [ {label: 'Jam', value: 25 }, |
||
| 7 | {label: 'Frosted', value: 40 }, |
||
| 8 | {label: 'Custard', value: 25 }, |
||
| 9 | {label: 'Sugar', value: 10 } ] |
||
| 10 | formatter: (y) -> "#{y}%" |
||
| 11 | |||
| 12 | it 'should contain 2 paths for each segment', -> |
||
| 13 | chart = Morris.Donut $.extend {}, defaults |
||
| 14 | $('#graph').find("path").size().should.equal 8 |
||
| 15 | |||
| 16 | it 'should contain 2 text elements for the label', -> |
||
| 17 | chart = Morris.Donut $.extend {}, defaults |
||
| 18 | $('#graph').find("text").size().should.equal 2 |
||
| 19 | |||
| 20 | describe 'svg attributes', -> |
||
| 21 | defaults = |
||
| 22 | element: 'graph' |
||
| 23 | data: [ {label: 'Jam', value: 25 }, |
||
| 24 | {label: 'Frosted', value: 40 }, |
||
| 25 | {label: 'Custard', value: 25 }, |
||
| 26 | {label: 'Sugar', value: 10 } ] |
||
| 27 | formatter: (y) -> "#{y}%" |
||
| 28 | colors: [ '#0B62A4', '#3980B5', '#679DC6', '#95BBD7'] |
||
| 29 | |||
| 30 | it 'should have a label with font size 15', -> |
||
| 31 | chart = Morris.Donut $.extend {}, defaults |
||
| 32 | $('#graph').find("text[font-size='15px']").size().should.equal 1 |
||
| 33 | |||
| 34 | it 'should have a label with font size 14', -> |
||
| 35 | chart = Morris.Donut $.extend {}, defaults |
||
| 36 | $('#graph').find("text[font-size='14px']").size().should.equal 1 |
||
| 37 | |||
| 38 | it 'should have a label with font-weight 800', -> |
||
| 39 | chart = Morris.Donut $.extend {}, defaults |
||
| 40 | $('#graph').find("text[font-weight='800']").size().should.equal 1 |
||
| 41 | |||
| 42 | it 'should have 1 paths with fill of first color', -> |
||
| 43 | chart = Morris.Donut $.extend {}, defaults |
||
| 44 | $('#graph').find("path[fill='#0b62a4']").size().should.equal 1 |
||
| 45 | |||
| 46 | it 'should have 1 paths with stroke of first color', -> |
||
| 47 | chart = Morris.Donut $.extend {}, defaults |
||
| 48 | $('#graph').find("path[stroke='#0b62a4']").size().should.equal 1 |
||
| 49 | |||
| 50 | it 'should have a path with white stroke', -> |
||
| 51 | chart = Morris.Donut $.extend {}, defaults |
||
| 52 | $('#graph').find("path[stroke='#ffffff']").size().should.equal 4 |
||
| 53 | |||
| 54 | it 'should have a path with stroke-width 3', -> |
||
| 55 | chart = Morris.Donut $.extend {}, defaults |
||
| 56 | $('#graph').find("path[stroke-width='3']").size().should.equal 4 |
||
| 57 | |||
| 58 | it 'should have a path with stroke-width 2', -> |
||
| 59 | chart = Morris.Donut $.extend {}, defaults |
||
| 60 | $('#graph').find("path[stroke-width='2']").size().should.equal 4 |
||
| 61 | |||
| 62 | describe 'setData', -> |
||
| 63 | defaults = |
||
| 64 | element: 'graph' |
||
| 65 | data: [ {label: 'One', value: 25 }, {label: "Two", value: 30} ] |
||
| 66 | colors: ['#ff0000', '#00ff00', '#0000ff'] |
||
| 67 | |||
| 68 | it 'should update the chart', -> |
||
| 69 | chart = Morris.Donut $.extend {}, defaults |
||
| 70 | $('#graph').find("path[stroke='#0000ff']").size().should.equal 0 |
||
| 71 | chart.setData [ |
||
| 72 | { label: 'One', value: 25 } |
||
| 73 | { label: 'Two', value: 30 } |
||
| 74 | { label: 'Three', value: 35 } |
||
| 75 | ] |
||
| 76 | $('#graph').find("path[stroke='#0000ff']").size().should.equal 1 |