cart.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. casper.test.begin('shopping-cart', 16, function (test) {
  2. casper
  3. .start('examples/shopping-cart/index.html')
  4. .wait(120) // api simulation
  5. .then(function () {
  6. test.assertElementCount('li', 3)
  7. test.assertElementCount('.cart button[disabled]', 1)
  8. test.assertSelectorHasText('li:nth-child(1)', 'iPad 4 Mini')
  9. test.assertSelectorHasText('.cart', 'Please add some products to cart')
  10. test.assertSelectorHasText('.cart', 'Total: $0.00')
  11. })
  12. .thenClick('li:nth-child(1) button', function () {
  13. test.assertSelectorHasText('.cart', 'iPad 4 Mini - $500.01 x 1')
  14. test.assertSelectorHasText('.cart', 'Total: $500.01')
  15. })
  16. .thenClick('li:nth-child(1) button', function () {
  17. test.assertSelectorHasText('.cart', 'iPad 4 Mini - $500.01 x 2')
  18. test.assertSelectorHasText('.cart', 'Total: $1,000.02')
  19. test.assertElementCount('li:nth-child(1) button[disabled]', 1)
  20. })
  21. .thenClick('li:nth-child(2) button', function () {
  22. test.assertSelectorHasText('.cart', 'H&M T-Shirt White - $10.99 x 1')
  23. test.assertSelectorHasText('.cart', 'Total: $1,011.01')
  24. })
  25. .thenClick('.cart button')
  26. .wait(120)
  27. .then(function () {
  28. test.assertSelectorHasText('.cart', 'Please add some products to cart')
  29. test.assertSelectorHasText('.cart', 'Total: $0.00')
  30. test.assertSelectorHasText('.cart', 'Checkout successful')
  31. test.assertElementCount('.cart button[disabled]', 1)
  32. })
  33. .run(function () {
  34. test.done()
  35. })
  36. })