Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3247882
D5358.id17791.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5358.id17791.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D5358: Added tests for spoiler regex
Attached
Detach File
Event Timeline
Log In to Comment