UNPKG

2.16 kBJavaScriptView Raw
1
2var Renderer = require("../../lib/renderer");
3
4describe ("Renderer", function() {
5
6 it ("should render bracket tags1", function() {
7 var text = "a [[Foo]] b";
8 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo\">Foo</a> b</p>\n");
9 });
10
11 it ("should render bracket tags2", function() {
12 var text = "a [[Foo]][[Foo]][[Foo]] b";
13 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo\">Foo</a><a class=\"internal\" href=\"/wiki/Foo\">Foo</a><a class=\"internal\" href=\"/wiki/Foo\">Foo</a> b</p>\n");
14 });
15
16 it ("should render bracket tags3", function() {
17 var text = "a [[Foo Bar]] b";
18 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo-Bar\">Foo Bar</a> b</p>\n");
19 });
20
21 it ("should render bracket tags4", function() {
22 var text = "a [[Foo]][[Bar]] b";
23 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo\">Foo</a><a class=\"internal\" href=\"/wiki/Bar\">Bar</a> b</p>\n");
24 });
25
26 it ("should render bracket tags5", function() {
27 var text = "a [[Foo]] [[Bar]] b";
28 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo\">Foo</a> <a class=\"internal\" href=\"/wiki/Bar\">Bar</a> b</p>\n");
29 });
30
31 it ("should render bracket tags6", function() {
32 var text = "a [[Il marito di Foo|Foobar]] [[Bar]] b";
33 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foobar\">Il marito di Foo</a> <a class=\"internal\" href=\"/wiki/Bar\">Bar</a> b</p>\n");
34 });
35
36 it ("should render bracket tags7", function() {
37 var text = "a [[Foo / Bar]] b";
38 expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo-%2B-Bar\">Foo / Bar</a> b</p>\n");
39 });
40
41 it ("should replace {{TOC}} with the table of contents", function() {
42 var text = "{{TOC}}\n\n # Heading 1 \n\n This is some text";
43 expect(Renderer.render(text)).to.be.equal("<ul>\n<li><p><a href=\"#heading-1\">Heading 1</a></p>\n<h1 id=\"heading-1\">Heading 1</h1>\n<p>This is some text</p>\n</li>\n</ul>\n");
44 });
45
46
47});