svg.js 1.8 KB

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