Page MenuHomePhabricator

D5447.diff
No OneTemporary

D5447.diff

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

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)

Event Timeline