Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3247802
D5447.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5447.diff
View Options
diff --git a/lib/shared/markdown.test.js b/lib/shared/markdown.test.js
--- a/lib/shared/markdown.test.js
+++ b/lib/shared/markdown.test.js
@@ -2,49 +2,52 @@
import { spoilerRegex } from './markdown.js';
+// Each of the below tests is subject to the following RegEx pattern:
+// Spoiler RegEx: /^\|\|([^\n]+?)\|\|/g
+
describe('spoilerRegex', () => {
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We expect a spoiler with a single space character to match.', () => {
expect('|| ||').toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We expect a spoiler with regular text + spaces to match (1).', () => {
expect('|| hello ||').toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We expect a spoiler with regular text + spaces to match (2).', () => {
expect('||SPOILER||').toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We expect a spoiler containing any number of || within it to match (1).', () => {
expect('|| || ||').toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We expect a spoiler containing any number of || within it to match (2).', () => {
expect('||||||').toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ 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('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We do not expect a spoiler containing a new line character to match (1).', () => {
expect('||\n||').not.toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We do not expect a spoiler containing a new line character to match (2).', () => {
expect('||\r\n||').not.toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We do not expect an empty spoiler to match.', () => {
expect('||||').not.toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ it('We expect a spoiler containing a single space to match, even when split across multiple lines.', () => {
expect('|| \
||').toMatch(spoilerRegex);
});
- it('spoilerRegex subject to ^||([^\n]+?)||/', () => {
+ 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, 6:56 AM (21 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496738
Default Alt Text
D5447.diff (2 KB)
Attached To
Mode
D5447: more descriptive it statements, moved the RegEx text to a comment
Attached
Detach File
Event Timeline
Log In to Comment