From 13202d0335e55f42e02cd3ae293374530adc0cc0 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Fri, 19 Jan 2018 23:58:56 +0100 Subject: [PATCH] test: add tests for `RegExpEscape` --- test/javascript/util/core.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/javascript/util/core.js b/test/javascript/util/core.js index b2cba9aa0..cd78116a8 100644 --- a/test/javascript/util/core.js +++ b/test/javascript/util/core.js @@ -69,6 +69,17 @@ describe('Foundation core', function() { }); }); + describe('RegExpEscape()', function() { + it('escape all special characters in a string for RegExp', function () { + const str = 'abc012-[]{}()*+?.,\\^$|#\s\t\r\n'; + const notstr = 'abc012-[]{}not-the-escaped-string'; + const reg = new RegExp(Foundation.RegExpEscape(str), 'g'); + + reg.test(str).should.be.true; + reg.test(notstr).should.be.false; + }); + }); + describe('reflow()', function() { }); -- 2.47.2