瀏覽代碼

add e2d tests for markdown example

Evan You 11 年之前
父節點
當前提交
8679163b30
共有 3 個文件被更改,包括 47 次插入1 次删除
  1. 1 1
      examples/markdown/index.html
  2. 5 0
      examples/markdown/marked.min.js
  3. 41 0
      test/e2e/markdown.js

+ 1 - 1
examples/markdown/index.html

@@ -5,7 +5,7 @@
     <title>Vue.js markdown editor example</title>
     <link rel="stylesheet" href="style.css">
     <script src="../../dist/vue.js"></script>
-    <script src="http://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script>
+    <script src="marked.min.js"></script>
   </head>
   <body>
 

文件差異過大導致無法顯示
+ 5 - 0
examples/markdown/marked.min.js


+ 41 - 0
test/e2e/markdown.js

@@ -0,0 +1,41 @@
+casper.test.begin('markdown', 4, function (test) {
+  
+  casper
+  .start('../../examples/markdown/index.html')
+  .then(function () {
+    test.assertEval(function () {
+      return document.querySelector('textarea').value === '# hello'
+    })
+    test.assertEval(function () {
+      return document.querySelector('#editor div')
+        .innerHTML === '<h1 id="hello">hello</h1>\n'
+    })
+  })
+  .then(function () {
+    this.sendKeys(
+      'textarea',
+      '## yo\n\n' +
+      '- test\n' +
+      '- hi\n\n'
+    )
+    // keyUp(13)
+  })
+  .then(function () {
+    test.assertEval(function () {
+      return document.querySelector('textarea').value
+        === '## yo\n\n- test\n- hi\n\n# hello'
+    })
+    test.assertEval(function () {
+      return document.querySelector('#editor div')
+        .innerHTML ===
+          '<h2 id="yo">yo</h2>\n' +
+          '<ul>\n<li>test</li>\n<li>hi</li>\n</ul>\n' +
+          '<h1 id="hello">hello</h1>\n'
+    })
+  })
+  // run
+  .run(function () {
+    test.done()
+  })
+
+})

部分文件因文件數量過多而無法顯示