From: Nicolas Coden Date: Fri, 19 Jan 2018 22:58:56 +0000 (+0100) Subject: test: add tests for `RegExpEscape` X-Git-Tag: v6.6.0~3^2~316^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13202d0335e55f42e02cd3ae293374530adc0cc0;p=thirdparty%2Ffoundation%2Ffoundation-sites.git test: add tests for `RegExpEscape` --- 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() { });