Version 1
[yaffs-website] / node_modules / es5-shim / tests / spec / s-regexp.js
diff --git a/node_modules/es5-shim/tests/spec/s-regexp.js b/node_modules/es5-shim/tests/spec/s-regexp.js
new file mode 100644 (file)
index 0000000..0b56ec1
--- /dev/null
@@ -0,0 +1,27 @@
+/* global describe, it, expect */
+
+describe('RegExp', function () {
+    'use strict';
+
+    describe('#toString()', function () {
+        describe('literals', function () {
+            it('should return correct flags and in correct order', function () {
+                expect(String(/pattern/)).toBe('/pattern/');
+                expect(String(/pattern/i)).toBe('/pattern/i');
+                expect(String(/pattern/mi)).toBe('/pattern/im');
+                expect(String(/pattern/im)).toBe('/pattern/im');
+                expect(String(/pattern/mgi)).toBe('/pattern/gim');
+            });
+        });
+
+        describe('objects', function () {
+            it('should return correct flags and in correct order', function () {
+                expect(String(new RegExp('pattern'))).toBe('/pattern/');
+                expect(String(new RegExp('pattern', 'i'))).toBe('/pattern/i');
+                expect(String(new RegExp('pattern', 'mi'))).toBe('/pattern/im');
+                expect(String(new RegExp('pattern', 'im'))).toBe('/pattern/im');
+                expect(String(new RegExp('pattern', 'mgi'))).toBe('/pattern/gim');
+            });
+        });
+    });
+});