svg.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* global stats, valueToPoint */
  2. casper.on("page.error", function(msg, trace) {
  3. console.log(JSON.stringify(trace, null, 2))
  4. })
  5. casper.test.begin('svg', 18, function (test) {
  6. casper
  7. .start('examples/svg/index.html')
  8. .then(function () {
  9. test.assertElementCount('g', 1)
  10. test.assertElementCount('polygon', 1)
  11. test.assertElementCount('circle', 1)
  12. test.assertElementCount('text', 6)
  13. test.assertElementCount('label', 6)
  14. test.assertElementCount('button', 7)
  15. test.assertElementCount('input[type="range"]', 6)
  16. test.assertEval(function () {
  17. var points = stats.map(function (stat, i) {
  18. var point = valueToPoint(stat.value, i, 6)
  19. return point.x + ',' + point.y
  20. }).join(' ')
  21. return document.querySelector('polygon').attributes[0].value === points
  22. })
  23. })
  24. .thenClick('button.remove', function () {
  25. test.assertElementCount('text', 5)
  26. test.assertElementCount('label', 5)
  27. test.assertElementCount('button', 6)
  28. test.assertElementCount('input[type="range"]', 5)
  29. test.assertEval(function () {
  30. var points = stats.map(function (stat, i) {
  31. var point = valueToPoint(stat.value, i, 5)
  32. return point.x + ',' + point.y
  33. }).join(' ')
  34. return document.querySelector('polygon').attributes[0].value === points
  35. })
  36. })
  37. .then(function () {
  38. this.fill('#add', {
  39. newlabel: 'foo'
  40. })
  41. })
  42. .thenClick('#add > button', function () {
  43. test.assertElementCount('text', 6)
  44. test.assertElementCount('label', 6)
  45. test.assertElementCount('button', 7)
  46. test.assertElementCount('input[type="range"]', 6)
  47. test.assertEval(function () {
  48. var points = stats.map(function (stat, i) {
  49. var point = valueToPoint(stat.value, i, 6)
  50. return point.x + ',' + point.y
  51. }).join(' ')
  52. return document.querySelector('polygon').attributes[0].value === points
  53. })
  54. })
  55. // run
  56. .run(function () {
  57. test.done()
  58. })
  59. })