markdown.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. casper.test.begin('markdown', 5, function (test) {
  2. casper
  3. .start('../../examples/markdown/index.html')
  4. .then(function () {
  5. test.assertEval(function () {
  6. return document.querySelector('textarea').value === '# hello'
  7. })
  8. test.assertEval(function () {
  9. return document.querySelector('#editor div')
  10. .innerHTML === '<h1 id="hello">hello</h1>\n'
  11. })
  12. })
  13. .then(function () {
  14. this.sendKeys(
  15. 'textarea',
  16. '## yo\n\n' +
  17. '- test\n' +
  18. '- hi\n\n'
  19. )
  20. // keyUp(13)
  21. })
  22. .then(function () {
  23. // assert the output is not updarted yet because of
  24. // debounce
  25. test.assertEval(function () {
  26. return document.querySelector('#editor div')
  27. .innerHTML === '<h1 id="hello">hello</h1>\n'
  28. })
  29. })
  30. .wait(300) // wait for debounce
  31. .then(function () {
  32. test.assertEval(function () {
  33. return document.querySelector('textarea').value
  34. === '## yo\n\n- test\n- hi\n\n# hello'
  35. })
  36. test.assertEval(function () {
  37. return document.querySelector('#editor div')
  38. .innerHTML ===
  39. '<h2 id="yo">yo</h2>\n' +
  40. '<ul>\n<li>test</li>\n<li>hi</li>\n</ul>\n' +
  41. '<h1 id="hello">hello</h1>\n'
  42. })
  43. })
  44. // run
  45. .run(function () {
  46. test.done()
  47. })
  48. })