]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
test: add tests for `RegExpEscape` 10868/head
authorNicolas Coden <nicolas@ncoden.fr>
Fri, 19 Jan 2018 22:58:56 +0000 (23:58 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Fri, 19 Jan 2018 22:58:56 +0000 (23:58 +0100)
test/javascript/util/core.js

index b2cba9aa002aefa710ff060251c2e57aee88ab72..cd78116a8794e690c361e33db425df77d53265c2 100644 (file)
@@ -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() {
   });