markdown.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. '## foo\n\n' +
  17. '- bar\n' +
  18. '- baz\n\n',
  19. { keepFocus: true }
  20. )
  21. // keyUp(13)
  22. })
  23. .then(function () {
  24. // assert the output is not updated yet because of
  25. // debounce
  26. test.assertEval(function () {
  27. return document.querySelector('#editor div')
  28. .innerHTML === '<h1 id="hello">hello</h1>\n'
  29. })
  30. })
  31. .wait(300) // wait for debounce
  32. .then(function () {
  33. test.assertEval(function () {
  34. return document.querySelector('textarea').value ===
  35. '## foo\n\n- bar\n- baz\n\n# hello'
  36. })
  37. test.assertEval(function () {
  38. return document.querySelector('#editor div')
  39. .innerHTML ===
  40. '<h2 id="foo">foo</h2>\n' +
  41. '<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n' +
  42. '<h1 id="hello">hello</h1>\n'
  43. })
  44. })
  45. // run
  46. .run(function () {
  47. test.done()
  48. })
  49. })