s-regexp.js 1.2 KB

1234567891011121314151617181920212223242526
  1. describe('RegExp', function () {
  2. 'use strict';
  3. describe('#toString()', function () {
  4. describe('literals', function () {
  5. it('should return correct flags and in correct order', function () {
  6. expect(String(/pattern/)).toBe('/pattern/');
  7. expect(String(/pattern/i)).toBe('/pattern/i');
  8. expect(String(/pattern/mi)).toBe('/pattern/im');
  9. expect(String(/pattern/im)).toBe('/pattern/im');
  10. expect(String(/pattern/mgi)).toBe('/pattern/gim');
  11. });
  12. });
  13. describe('objects', function () {
  14. it('should return correct flags and in correct order', function () {
  15. /* eslint prefer-regex-literals: 0 */
  16. expect(String(new RegExp('pattern'))).toBe('/pattern/');
  17. expect(String(new RegExp('pattern', 'i'))).toBe('/pattern/i');
  18. expect(String(new RegExp('pattern', 'mi'))).toBe('/pattern/im');
  19. expect(String(new RegExp('pattern', 'im'))).toBe('/pattern/im');
  20. expect(String(new RegExp('pattern', 'mgi'))).toBe('/pattern/gim');
  21. });
  22. });
  23. });
  24. });