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 @@ -51,4 +51,34 @@ expect('|| \n\ ||').not.toMatch(spoilerRegex); }); + + it("We expect to extract 'hello' from the following spoiler: ||hello||", () => { + const spoiler = '||hello||'; + const extracted = spoiler.match(spoilerRegex); + expect(extracted ? extracted[0] : null).toMatch('hello'); + }); + + it("We expect to extract '||' from the following spoiler: ||||||", () => { + const spoiler = '||||||'; + const extracted = spoiler.match(spoilerRegex); + expect(extracted ? extracted[0] : null).toMatch('||'); + }); + + it("We expect to extract ' ' from the following spoiler: || || ||", () => { + const spoiler = '|| || ||'; + const extracted = spoiler.match(spoilerRegex); + expect(extracted ? extracted[0] : null).toMatch(' '); + }); + + it("We expect to extract '||THISISASPOILER||' from the following spoiler: ||||THISISASPOILER||||", () => { + const spoiler = '||||THISISASPOILER||||'; + const extracted = spoiler.match(spoilerRegex); + expect(extracted ? extracted[0] : null).toMatch('||THISISASPOILER||'); + }); + + it("We expect to extract '' from the following spoiler: || \\|\\| ||", () => { + const spoiler = '|| \\|\\| ||'; + const extracted = spoiler.match(spoilerRegex); + expect(extracted ? extracted[0] : null).toMatch(' \\|\\| '); + }); });