From f92f2fdea631058bfca204dc0a620b3cc0188868 Mon Sep 17 00:00:00 2001 From: VonC <vonc@laposte.net> Date: Sun, 27 Oct 2013 19:57:12 +0100 Subject: [PATCH] Add unit-tests for attributes in mardown elements. Test paragraphs, list items and img attributes. --- test/red-curtain-50x50.jpg | Bin 0 -> 1995 bytes test/test-element-attributes-markdown.html | 84 +++++++++++++++++++++ test/test-element-attributes-markdown.js | 38 ++++++++++ 3 files changed, 122 insertions(+) create mode 100644 test/red-curtain-50x50.jpg create mode 100644 test/test-element-attributes-markdown.html create mode 100644 test/test-element-attributes-markdown.js diff --git a/test/red-curtain-50x50.jpg b/test/red-curtain-50x50.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ddfe7a637d747dedc7c7c71a01431e7e76e0eb6f GIT binary patch literal 1995 zcmbW!XH=6}8UWxg`O-)TNgx4q1`|LjA}9z$Q$sOS1%paeihwjh2}KZu6~qE4V1$fV zkY+5$QCSgD9EgD6Vr)nY76?KFL<u1pV#qgPX3y?9`)haK``-KGwsW8RLW9r<K=g9+ zbOT^80D!3)04V`SS3idH4qrb9T1=FA{DJ5gTDqmhI+{sZN?cM5&C|=B=CzICPD}sA z%5)7aIW1yeTxuq5Bh7vt78(Xz0T2#fN>w0KiNqk02m}&~Mx!w5Sao$A7Kg)YXcF-n zBn=#ns7)kkktr04IzdNQo2;uzrjVB|fq|+s2&5VksYb@*@Z|qFpf-Sn0jvNk5M}_t zNidKEgE|1J3W<dM8NfdS23Nfig~q61ajFfCL;wy0K{x_jdbMizVbwZ-AR#sNEuB$X z%m}nWGTG`#SvAJc<qnVH_iA?K`aP^XHLSLd?y}{pjEqf8S6kcsVrysb;JTUN=I-I? zwSC7<|A4@t;K-=xy)m(I@hPck=?61159J>%IClKR$-*=2v*i_>U(Z$6)YjEs;a<IV zz2Wb78}BvUZ+`H&y`%F<SNGF@yzYI|*FP{gBp4NreH@<<eVUvS&q?N`-@eNh<V!9X z0RF{Njeo)Z!$nfL;0OeWKrgvq@Pn!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#I7yH|X69>hi`7(e@GgW|Hj0w7Fg`x8fFeP?GI#<@L2WXRq;1ig;Gmf}u`^-J}f7 zM8B0W*e}DPWFI=H#Jd+=d6gC=YUgLPHN8bTPB%EKQT8vmNy27dtRhhy#)E*LgA)$< z)URr3?~$0lDbM>tSP&V+sM{GfqwQ#gk_@TV^$$Jz$@n^!*)HE#=~t;H^4pVvp@x0< zcO3`8ammh$D2)SA*=foPJHywNRx=$_2fnN=lCgCvN5|BBUQVQYGt5IC?)Ka7Eq!#4 z9-6)EM^J{5D74px?<Tf>r-|RR)n}S-{6c88;jFX7F=-$1vZDH7N*HE3j57bQRVRT{ zxst$*<=9I2k+GtQJXGngFMkx!awwu!eCkFwz4+Htb2?`x=9oG|CwqWEJXc{>);}Yf z?SFV}QU`zTvqgPlY5tRsEUuLD$>na0ZBK(`HD^Oj!E)&rF4M7d-ise6N_qPw$8?!2 z=>G6&eE3uGroeH*D&rN>F?3Kyn0|?93un9J`N)BUOZ7IUl2m){sa-Qyvi>H!X#xQi zwUU|^vmXoyc*Ka1Mny}%T5_r^&ecA#JM}yW?Y2qyfPi$><6q*g>2BzuwB*?)SNH@} zZ*-`7_KJ}ZBJ=G#wp+RAt+0fE*S@U&$Up^Mc&^-qPZbQU1l8-DJZRr|6Te5hcuX@W oot#{?sw^S;hm<<o`s`SwWcePpYWlNzNmsr2P6~s(4Gj(b0hFJ9_5c6? literal 0 HcmV?d00001 diff --git a/test/test-element-attributes-markdown.html b/test/test-element-attributes-markdown.html new file mode 100644 index 0000000..e547d16 --- /dev/null +++ b/test/test-element-attributes-markdown.html @@ -0,0 +1,84 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Markdown</title> + + <link rel="stylesheet" href="../css/reveal.min.css"> + <link rel="stylesheet" href="qunit-1.12.0.css"> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal" style="display: none;"> + + <div class="slides"> + + <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n"></section> --> + + <!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes --> + <section data-markdown data-separator="^\n---\n$" + data-vertical="^\n--\n$" + data-element-attributes="{_\s*?([^}]+?)}"> + <script type="text/template"> + ## Slide 1.1 {_class="fragment fade-out" data-fragment-index="1"} + + -- + + ## Slide 1.2 {_class="fragment shrink"} + + Paragraph 1 {_class="fragment grow"} + + Paragraph 2 {_class="fragment grow"} + + - list item 1 {_class="fragment roll-in"} + - list item 2 {_class="fragment roll-in"} + - list item 3 {_class="fragment roll-in"} + + + --- + + ## Slide 2 + + + Paragraph 1.2 + multi-line {_class="fragment highlight-red"} + + Paragraph 2.2 {_class="fragment highlight-red"} + + Paragraph 2.3 {_class="fragment highlight-red"} + + Paragraph 2.4 {_class="fragment highlight-red"} + + - list item 1 {_class="fragment highlight-green"} + - list item 2 {_class="fragment highlight-green"} + - list item 3 {_class="fragment highlight-green"} + - list item 4 {_class="fragment highlight-green"} + - list item 5 {_class="fragment highlight-green"} + +Test + + + + </script> + </section> + + </div> + + </div> + + <script src="../lib/js/head.min.js"></script> + <script src="../js/reveal.min.js"></script> + <script src="../plugin/markdown/marked.js"></script> + <script src="../plugin/markdown/markdown.js"></script> + <script src="qunit-1.12.0.js"></script> + + <script src="test-element-attributes-markdown.js"></script> + + </body> +</html> diff --git a/test/test-element-attributes-markdown.js b/test/test-element-attributes-markdown.js new file mode 100644 index 0000000..e79806c --- /dev/null +++ b/test/test-element-attributes-markdown.js @@ -0,0 +1,38 @@ + + +Reveal.addEventListener( 'ready', function() { + + QUnit.module( 'Markdown' ); + + test( 'Vertical separator', function() { + strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' ); + }); + + + test( 'Attributes on vertical slides header', function() { + strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' ); + strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' ); + }); + + test( 'Attributes on vertical slides paragraphs', function() { + strictEqual( document.querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' ); + }); + + test( 'Attributes on vertical slides list items', function() { + strictEqual( document.querySelectorAll( '.reveal .slides section>section li.fragment.roll-in' ).length, 3, 'found a vertical slide with three list items with class fragment.roll-in' ); + }); + + test( 'Attributes on horizontal slides paragraphs', function() { + strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' ); + }); + test( 'Attributes on horizontal slides list items', function() { + strictEqual( document.querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' ); + }); + test( 'Attributes on horizontal slides list items', function() { + strictEqual( document.querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' ); + }); + +} ); + +Reveal.initialize(); + -- GitLab