From 3a41400d6383eca3b3c02bbbfdf1cb4fe6945d89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9gis=20Hanol?= \nx++\n
");
- });
- it("supports spoiler tags", function() {
- return expect(format("[spoiler]it's a sled[/spoiler]")).toBe("it's a sled");
- });
- it("links images", function() {
- return expect(format("[img]http://eviltrout.com/eviltrout.png[/img]")).toBe("");
- });
- it("supports [url] without a title", function() {
- return expect(format("[url]http://bettercallsaul.com[/url]")).toBe("http://bettercallsaul.com");
- });
- return it("supports [email] without a title", function() {
- return expect(format("[email]eviltrout@mailinator.com[/email]")).toBe("eviltrout@mailinator.com");
- });
+
+describe("Discourse.BBCode", function() {
+ var format = Discourse.BBCode.format;
+
+ describe('default replacer', function() {
+
+ describe("simple tags", function() {
+
+ it("bolds text", function() {
+ expect(format("[b]strong[/b]")).toBe("strong");
});
- describe("lists", function() {
- it("creates an ul", function() {
- return expect(format("[ul][li]option one[/li][/ul]")).toBe("
");
- });
- return it("creates an ol", function() {
- return expect(format("[ol][li]option one[/li][/ol]")).toBe("
");
- });
+
+ it("italics text", function() {
+ expect(format("[i]emphasis[/i]")).toBe("emphasis");
});
- describe("color", function() {
- it("supports [color=] with a short hex value", function() {
- return expect(format("[color=#00f]blue[/color]")).toBe("blue");
- });
- it("supports [color=] with a long hex value", function() {
- return expect(format("[color=#ffff00]yellow[/color]")).toBe("yellow");
- });
- it("supports [color=] with an html color", function() {
- return expect(format("[color=red]red[/color]")).toBe("red");
- });
- return it("it performs a noop on invalid input", function() {
- return expect(format("[color=javascript:alert('wat')]noop[/color]")).toBe("noop");
- });
+
+ it("underlines text", function() {
+ expect(format("[u]underlined[/u]")).toBe("underlined");
});
- describe("tags with arguments", function() {
- it("supports [size=]", function() {
- return expect(format("[size=35]BIG[/size]")).toBe("BIG");
- });
- it("supports [url] with a title", function() {
- return expect(format("[url=http://bettercallsaul.com]better call![/url]")).toBe("better call!");
- });
- return it("supports [email] with a title", function() {
- return expect(format("[email=eviltrout@mailinator.com]evil trout[/email]")).toBe("evil trout");
- });
+
+ it("strikes-through text", function() {
+ expect(format("[s]strikethrough[/s]")).toBe("strikethrough");
});
- return describe("more complicated", function() {
- it("can nest tags", function() {
- return expect(format("[u][i]abc[/i][/u]")).toBe("abc");
- });
- return it("can bold two things on the same line", function() {
- return expect(format("[b]first[/b] [b]second[/b]")).toBe("first second");
- });
+
+ it("makes code into pre", function() {
+ expect(format("[code]\nx++\n[/code]")).toBe("\nx++\n
");
});
+
+ it("supports spoiler tags", function() {
+ expect(format("[spoiler]it's a sled[/spoiler]")).toBe("it's a sled");
+ });
+
+ it("links images", function() {
+ expect(format("[img]http://eviltrout.com/eviltrout.png[/img]")).toBe("");
+ });
+
+ it("supports [url] without a title", function() {
+ expect(format("[url]http://bettercallsaul.com[/url]")).toBe("http://bettercallsaul.com");
+ });
+
+ it("supports [email] without a title", function() {
+ expect(format("[email]eviltrout@mailinator.com[/email]")).toBe("eviltrout@mailinator.com");
+ });
+
});
- return describe('email environment', function() {
- describe("simple tags", function() {
- it("bolds text", function() {
- return expect(format("[b]strong[/b]", {
- environment: 'email'
- })).toBe("strong");
- });
- it("italics text", function() {
- return expect(format("[i]emphasis[/i]", {
- environment: 'email'
- })).toBe("emphasis");
- });
- it("underlines text", function() {
- return expect(format("[u]underlined[/u]", {
- environment: 'email'
- })).toBe("underlined");
- });
- it("strikes-through text", function() {
- return expect(format("[s]strikethrough[/s]", {
- environment: 'email'
- })).toBe("
strikethrough");
- });
- it("makes code into pre", function() {
- return expect(format("[code]\nx++\n[/code]", {
- environment: 'email'
- })).toBe("\nx++\n
");
- });
- it("supports spoiler tags", function() {
- return expect(format("[spoiler]it's a sled[/spoiler]", {
- environment: 'email'
- })).toBe("it's a sled");
- });
- it("links images", function() {
- return expect(format("[img]http://eviltrout.com/eviltrout.png[/img]", {
- environment: 'email'
- })).toBe("");
- });
- it("supports [url] without a title", function() {
- return expect(format("[url]http://bettercallsaul.com[/url]", {
- environment: 'email'
- })).toBe("http://bettercallsaul.com");
- });
- return it("supports [email] without a title", function() {
- return expect(format("[email]eviltrout@mailinator.com[/email]", {
- environment: 'email'
- })).toBe("eviltrout@mailinator.com");
- });
+
+ describe("lists", function() {
+
+ it("creates an ul", function() {
+ expect(format("[ul][li]option one[/li][/ul]")).toBe("
");
});
- describe("lists", function() {
- it("creates an ul", function() {
- return expect(format("[ul][li]option one[/li][/ul]", {
- environment: 'email'
- })).toBe("
");
- });
- return it("creates an ol", function() {
- return expect(format("[ol][li]option one[/li][/ol]", {
- environment: 'email'
- })).toBe("
");
- });
- });
- describe("color", function() {
- it("supports [color=] with a short hex value", function() {
- return expect(format("[color=#00f]blue[/color]", {
- environment: 'email'
- })).toBe("blue");
- });
- it("supports [color=] with a long hex value", function() {
- return expect(format("[color=#ffff00]yellow[/color]", {
- environment: 'email'
- })).toBe("yellow");
- });
- it("supports [color=] with an html color", function() {
- return expect(format("[color=red]red[/color]", {
- environment: 'email'
- })).toBe("red");
- });
- return it("it performs a noop on invalid input", function() {
- return expect(format("[color=javascript:alert('wat')]noop[/color]", {
- environment: 'email'
- })).toBe("noop");
- });
- });
- return describe("tags with arguments", function() {
- it("supports [size=]", function() {
- return expect(format("[size=35]BIG[/size]", {
- environment: 'email'
- })).toBe("BIG");
- });
- it("supports [url] with a title", function() {
- return expect(format("[url=http://bettercallsaul.com]better call![/url]", {
- environment: 'email'
- })).toBe("better call!");
- });
- return it("supports [email] with a title", function() {
- return expect(format("[email=eviltrout@mailinator.com]evil trout[/email]", {
- environment: 'email'
- })).toBe("evil trout");
- });
+
+ it("creates an ol", function() {
+ expect(format("[ol][li]option one[/li][/ol]")).toBe("
");
});
+
});
+
+ describe("color", function() {
+
+ it("supports [color=] with a short hex value", function() {
+ expect(format("[color=#00f]blue[/color]")).toBe("blue");
+ });
+
+ it("supports [color=] with a long hex value", function() {
+ expect(format("[color=#ffff00]yellow[/color]")).toBe("yellow");
+ });
+
+ it("supports [color=] with an html color", function() {
+ expect(format("[color=red]red[/color]")).toBe("red");
+ });
+
+ it("it performs a noop on invalid input", function() {
+ expect(format("[color=javascript:alert('wat')]noop[/color]")).toBe("noop");
+ });
+
+ });
+
+ describe("tags with arguments", function() {
+
+ it("supports [size=]", function() {
+ expect(format("[size=35]BIG[/size]")).toBe("BIG");
+ });
+
+ it("supports [url] with a title", function() {
+ expect(format("[url=http://bettercallsaul.com]better call![/url]")).toBe("better call!");
+ });
+
+ it("supports [email] with a title", function() {
+ expect(format("[email=eviltrout@mailinator.com]evil trout[/email]")).toBe("evil trout");
+ });
+
+ });
+
+ describe("more complicated", function() {
+
+ it("can nest tags", function() {
+ expect(format("[u][i]abc[/i][/u]")).toBe("abc");
+ });
+
+ it("can bold two things on the same line", function() {
+ expect(format("[b]first[/b] [b]second[/b]")).toBe("first second");
+ });
+
+ });
+
+ describe("quoting", function() {
+
+ it("can quote", function() {
+ expect(format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]", { lookupAvatar: false })).toBe("
"); + }); + + it("can nest quotes", function() { + expect(format("[quote=\"eviltrout, post:1, topic:1\"]abc[quote=\"eviltrout, post:2, topic:2\"]nested[/quote][/quote]", { lookupAvatar: false })).toBe("
\n"); + }); + + it("can handle more than one quote", function() { + expect(format("before[quote=\"eviltrout, post:1, topic:1\"]first[/quote]middle[quote=\"eviltrout, post:2, topic:2\"]second[/quote]after", { lookupAvatar: false })).toBe("before
first\n
middle
second\n
after");
+ });
+
+ });
+
});
+ describe('email environment', function() {
+ describe("simple tags", function() {
+
+ it("bolds text", function() {
+ expect(format("[b]strong[/b]", { environment: 'email' })).toBe("strong");
+ });
+
+ it("italics text", function() {
+ expect(format("[i]emphasis[/i]", { environment: 'email' })).toBe("emphasis");
+ });
+
+ it("underlines text", function() {
+ expect(format("[u]underlined[/u]", { environment: 'email' })).toBe("underlined");
+ });
+
+ it("strikes-through text", function() {
+ expect(format("[s]strikethrough[/s]", { environment: 'email' })).toBe("strikethrough");
+ });
+
+ it("makes code into pre", function() {
+ expect(format("[code]\nx++\n[/code]", { environment: 'email' })).toBe("
\nx++\n"); + }); + + it("supports spoiler tags", function() { + expect(format("[spoiler]it's a sled[/spoiler]", { environment: 'email' })).toBe("it's a sled"); + }); + + it("links images", function() { + expect(format("[img]http://eviltrout.com/eviltrout.png[/img]", { environment: 'email' })).toBe("