area_spec.coffee 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. describe 'Morris.Area', ->
  2. describe 'svg structure', ->
  3. defaults =
  4. element: 'graph'
  5. data: [{x: '2012 Q1', y: 1}, {x: '2012 Q2', y: 1}]
  6. lineColors: [ '#0b62a4', '#7a92a3']
  7. gridLineColor: '#aaa'
  8. xkey: 'x'
  9. ykeys: ['y']
  10. labels: ['Y']
  11. it 'should contain a line path for each line', ->
  12. chart = Morris.Area $.extend {}, defaults
  13. $('#graph').find("path[stroke='#0b62a4']").size().should.equal 1
  14. it 'should contain a path with stroke-width 0 for each line', ->
  15. chart = Morris.Area $.extend {}, defaults
  16. $('#graph').find("path[stroke='#0b62a4']").size().should.equal 1
  17. it 'should contain 5 grid lines', ->
  18. chart = Morris.Area $.extend {}, defaults
  19. $('#graph').find("path[stroke='#aaaaaa']").size().should.equal 5
  20. it 'should contain 9 text elements', ->
  21. chart = Morris.Area $.extend {}, defaults
  22. $('#graph').find("text").size().should.equal 9
  23. describe 'svg attributes', ->
  24. defaults =
  25. element: 'graph'
  26. data: [{x: '2012 Q1', y: 1}, {x: '2012 Q2', y: 1}]
  27. xkey: 'x'
  28. ykeys: ['y']
  29. labels: ['Y']
  30. lineColors: [ '#0b62a4', '#7a92a3']
  31. lineWidth: 3
  32. pointWidths: [5]
  33. pointStrokeColors: ['#ffffff']
  34. gridLineColor: '#aaa'
  35. gridStrokeWidth: 0.5
  36. gridTextColor: '#888'
  37. gridTextSize: 12
  38. it 'should not be cumulative if behaveLikeLine', ->
  39. chart = Morris.Area $.extend {}, defaults, behaveLikeLine: true
  40. chart.cumulative.should.equal false
  41. it 'should have a line with transparent fill if behaveLikeLine', ->
  42. chart = Morris.Area $.extend {}, defaults, behaveLikeLine: true
  43. $('#graph').find("path[fill-opacity='0.8']").size().should.equal 1
  44. it 'should not have a line with transparent fill', ->
  45. chart = Morris.Area $.extend {}, defaults
  46. $('#graph').find("path[fill-opacity='0.8']").size().should.equal 0
  47. it 'should have a line with the fill of a modified line color', ->
  48. chart = Morris.Area $.extend {}, defaults
  49. $('#graph').find("path[fill='#0b62a4']").size().should.equal 0
  50. $('#graph').find("path[fill='#7a92a3']").size().should.equal 0