1 | var namer = require("../../lib/namer");
|
2 |
|
3 | describe("namer", function() {
|
4 |
|
5 | beforeEach(function () {
|
6 | namer.configOverride();
|
7 | });
|
8 |
|
9 | describe("configOverride method", function() {
|
10 |
|
11 | it ("should override some config parameters", function() {
|
12 | expect(namer.getConfig().pages.title.asciiOnly).to.be.false;
|
13 | namer.configOverride({
|
14 | pages: {
|
15 | title: {
|
16 | asciiOnly: true
|
17 | }
|
18 | }
|
19 | });
|
20 | expect(namer.getConfig().pages.title.asciiOnly).to.be.true;
|
21 | });
|
22 |
|
23 | });
|
24 |
|
25 | describe("wikify method", function() {
|
26 |
|
27 | it ("should wikify a string with the default settings", function() {
|
28 |
|
29 | expect(namer.wikify("34")).to.equal("34");
|
30 | expect(namer.wikify("")).to.equal("");
|
31 | expect(namer.wikify(" ")).to.equal("");
|
32 | expect(namer.wikify("hello_Sidebar")).to.equal("hello_Sidebar");
|
33 | expect(namer.wikify("_Sidebar")).to.equal("_Sidebar");
|
34 | expect(namer.wikify("nell'aria")).to.equal("nell'aria");
|
35 | expect(namer.wikify("lento lento lentissimo")).to.equal("lento--lento---lentissimo");
|
36 | expect(namer.wikify("nell - aria")).to.equal("nell---aria");
|
37 | expect(namer.wikify(" nell - aria ")).to.equal("nell---aria");
|
38 | expect(namer.wikify("Caffé")).to.equal("Caffé");
|
39 | expect(namer.wikify("Caffé corretto!")).to.equal("Caffé-corretto!");
|
40 | expect(namer.wikify("Caff<p>e</p> senza schiuma")).to.equal("Caffpe+p-senza-schiuma");
|
41 | expect(namer.wikify("Per favore: nessun, dico; E un punto...")).to.equal("Per-favore:-nessun,-dico;-E-un-punto...");
|
42 | expect(namer.wikify("prova.md")).to.equal("prova.md");
|
43 | });
|
44 |
|
45 | it ("should wikify a string with asciiOnly true", function() {
|
46 | namer.configOverride({
|
47 | pages: {
|
48 | title: {
|
49 | asciiOnly: true
|
50 | }
|
51 | }
|
52 | });
|
53 |
|
54 | expect(namer.wikify("hello_Sidebar")).to.equal("hello_Sidebar");
|
55 | expect(namer.wikify("_Sidebar")).to.equal("_Sidebar");
|
56 | expect(namer.wikify("nell'aria")).to.equal("nellaria");
|
57 | expect(namer.wikify("Caffé")).to.equal("Caffe");
|
58 | expect(namer.wikify("àéîöū")).to.equal("aeiou");
|
59 | expect(namer.wikify("Caffé corretto!")).to.equal("Caffe-corretto");
|
60 | expect(namer.wikify("Per favore: nessun, dico; E un punto...")).to.equal("Per-favore-nessun-dico-E-un-punto");
|
61 | expect(namer.wikify("prova.md")).to.equal("provamd");
|
62 |
|
63 | });
|
64 |
|
65 | it ("should wikify a string with lowercase true", function() {
|
66 | namer.configOverride({
|
67 | pages: {
|
68 | title: {
|
69 | lowercase: true
|
70 | }
|
71 | }
|
72 | });
|
73 | expect(namer.wikify("hello_sidebar")).to.equal("hello_sidebar");
|
74 | expect(namer.wikify("_sidebar")).to.equal("_sidebar");
|
75 | expect(namer.wikify("nell'aria")).to.equal("nell'aria");
|
76 | expect(namer.wikify("Caffé")).to.equal("caffé");
|
77 | expect(namer.wikify("Caffé corretto!")).to.equal("caffé-corretto!");
|
78 | expect(namer.wikify("È@@@É")).to.equal("è@@@é");
|
79 | });
|
80 |
|
81 | it ("should wikify a string with slashes", function() {
|
82 | expect(namer.wikify("/1/")).to.equal("+1+");
|
83 | expect(namer.wikify("1/")).to.equal("1+");
|
84 | expect(namer.wikify("/1")).to.equal("+1");
|
85 | expect(namer.wikify("1//")).to.equal("1++");
|
86 | expect(namer.wikify("///")).to.equal("+++");
|
87 | });
|
88 |
|
89 | it ("should wikify a string with the defaults of Jingo < 1.0", function() {
|
90 | namer.configOverride({
|
91 | pages: {
|
92 | title: {
|
93 | asciiOnly: true,
|
94 | replaceWs: true,
|
95 | lowercase: true
|
96 | }
|
97 | }
|
98 | });
|
99 | expect(namer.wikify("_Sidebar")).to.equal("_sidebar");
|
100 | expect(namer.wikify("_FOOTER")).to.equal("_footer");
|
101 | expect(namer.wikify("CoffeE")).to.equal("coffee");
|
102 | expect(namer.wikify("nell'aria")).to.equal("nellaria");
|
103 | expect(namer.wikify("lento lento lentissimo")).to.equal("lento--lento---lentissimo");
|
104 | expect(namer.wikify("nell - aria")).to.equal("nell---aria");
|
105 | expect(namer.wikify(" nell - aria ")).to.equal("nell---aria");
|
106 | expect(namer.wikify("Caffé")).to.equal("caffe");
|
107 | expect(namer.wikify("Caffé corretto!")).to.equal("caffe-corretto");
|
108 | expect(namer.wikify("Caff<p>e</p> senza schiuma")).to.equal("caffpep-senza-schiuma");
|
109 | expect(namer.wikify("Per favore: nessun, dico; E un punto...")).to.equal("per-favore-nessun-dico-e-un-punto");
|
110 | });
|
111 | });
|
112 |
|
113 | describe("unwikify method", function() {
|
114 |
|
115 | it ("should unwikify a string with the default settings", function() {
|
116 |
|
117 | expect(namer.unwikify("34")).to.equal("34");
|
118 | expect(namer.unwikify("carne-fresca")).to.equal("carne fresca");
|
119 | expect(namer.unwikify("carne fresca")).to.equal("carne fresca");
|
120 | expect(namer.unwikify("Carne Fresca")).to.equal("Carne Fresca");
|
121 | });
|
122 |
|
123 | it ("should unwikify a string with lowercase true", function() {
|
124 |
|
125 | namer.configOverride({
|
126 | pages: {
|
127 | title: {
|
128 | lowercase: true
|
129 | }
|
130 | }
|
131 | });
|
132 |
|
133 | expect(namer.unwikify("34")).to.equal("34");
|
134 | expect(namer.unwikify("disastro")).to.equal("Disastro");
|
135 | expect(namer.unwikify("carne-fresca")).to.equal("Carne Fresca");
|
136 | expect(namer.unwikify("carne fresca")).to.equal("Carne Fresca");
|
137 | expect(namer.unwikify("Carne Fresca")).to.equal("Carne Fresca");
|
138 | });
|
139 |
|
140 | it ("should unwikify a string with replaceWs true", function() {
|
141 |
|
142 | namer.configOverride({
|
143 | pages: {
|
144 | title: {
|
145 | replaceWs: true
|
146 | }
|
147 | }
|
148 | });
|
149 |
|
150 | expect(namer.unwikify("34")).to.equal("34");
|
151 | expect(namer.unwikify("disastro")).to.equal("disastro");
|
152 | expect(namer.unwikify("carne-fresca")).to.equal("carne fresca");
|
153 | expect(namer.unwikify("carne fresca")).to.equal("carne fresca");
|
154 | expect(namer.unwikify("Carne Fresca")).to.equal("Carne Fresca");
|
155 | });
|
156 |
|
157 | });
|
158 | }); |
\ | No newline at end of file |