repeated-primitive.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* global numbers */
  2. casper.test.begin('Repeated Primitives', 8, function (test) {
  3. casper
  4. .start('./fixtures/repeated-primitive.html')
  5. .then(function () {
  6. test.assertSelectorHasText('p:nth-child(1)', '1')
  7. test.assertSelectorHasText('p:nth-child(2)', '2')
  8. test.assertSelectorHasText('p:nth-child(3)', 'text')
  9. })
  10. // click everything to test event handlers (delegated)
  11. .thenClick('p:nth-child(1)', function () {
  12. test.assertSelectorHasText('p:nth-child(1)', '1 modified')
  13. })
  14. .thenClick('p:nth-child(2)', function () {
  15. test.assertSelectorHasText('p:nth-child(2)', '2 modified')
  16. })
  17. .thenClick('p:nth-child(3)', function () {
  18. test.assertSelectorHasText('p:nth-child(3)', 'text modified')
  19. })
  20. // more clicks
  21. .thenClick('p:nth-child(1)', function () {
  22. test.assertSelectorHasText('p:nth-child(1)', '1 modified modified')
  23. })
  24. .then(function () {
  25. test.assertEvalEquals(function () {
  26. return numbers
  27. }, ['1 modified modified', '2 modified', 'text modified'])
  28. })
  29. .run(function () {
  30. test.done()
  31. })
  32. })