Page MenuHomePhabricator

D5358.id17791.diff
No OneTemporary

D5358.id17791.diff

diff --git a/lib/shared/markdown.test.js b/lib/shared/markdown.test.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/markdown.test.js
@@ -0,0 +1,54 @@
+// @flow
+
+import { spoilerRegex } from './markdown.js';
+
+// Each of the below tests is subject to the following RegEx pattern:
+// Spoiler RegEx: /^\|\|([^\n]+?)\|\|/g
+
+describe('spoilerRegex', () => {
+ it('We expect a spoiler with a single space character to match.', () => {
+ expect('|| ||').toMatch(spoilerRegex);
+ });
+
+ it('We expect a spoiler with regular text + spaces to match (1).', () => {
+ expect('|| hello ||').toMatch(spoilerRegex);
+ });
+
+ it('We expect a spoiler with regular text + spaces to match (2).', () => {
+ expect('||SPOILER||').toMatch(spoilerRegex);
+ });
+
+ it('We expect a spoiler containing any number of || within it to match (1).', () => {
+ expect('|| || ||').toMatch(spoilerRegex);
+ });
+
+ it('We expect a spoiler containing any number of || within it to match (2).', () => {
+ expect('||||||').toMatch(spoilerRegex);
+ });
+
+ it('We expect a spoiler containing any number of || within it, as well as regular text + spaces, to match.', () => {
+ expect('||SPOILER||SPOILER||').toMatch(spoilerRegex);
+ });
+
+ it('We do not expect a spoiler containing a new line character to match (1).', () => {
+ expect('||\n||').not.toMatch(spoilerRegex);
+ });
+
+ it('We do not expect a spoiler containing a new line character to match (2).', () => {
+ expect('||\r\n||').not.toMatch(spoilerRegex);
+ });
+
+ it('We do not expect an empty spoiler to match.', () => {
+ expect('||||').not.toMatch(spoilerRegex);
+ });
+
+ it('We expect a spoiler containing a single space to match, even when split across multiple lines.', () => {
+ expect('|| \
+ ||').toMatch(spoilerRegex);
+ });
+
+ it('We do not expect a spoiler containing a new line character to match (3).', () => {
+ expect('|| \n\
+ ||').not.toMatch(spoilerRegex);
+ });
+});

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 7:23 AM (20 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496563
Default Alt Text
D5358.id17791.diff (1 KB)

Event Timeline