Skip to content

Commit

Permalink
Tests for RegExp, toString should return correct flags and in correct…
Browse files Browse the repository at this point in the history
… order
  • Loading branch information
Xotic750 committed Dec 9, 2015
1 parent 568c3e3 commit ce03328
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/spec/s-regexp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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(/pattern/.toString()).toBe('/pattern/');
expect(/pattern/i.toString()).toBe('/pattern/i');
expect(/pattern/mi.toString()).toBe('/pattern/im');
expect(/pattern/im.toString()).toBe('/pattern/im');
expect(/pattern/mgi.toString()).toBe('/pattern/gim');
});
});
describe('objects', function () {
it('should return correct flags and in correct order', function () {
expect(new RegExp('pattern').toString()).toBe('/pattern/');
expect(new RegExp('pattern', 'i').toString()).toBe('/pattern/i');
expect(new RegExp('pattern', 'mi').toString()).toBe('/pattern/im');
expect(new RegExp('pattern', 'im').toString()).toBe('/pattern/im');
expect(new RegExp('pattern', 'mgi').toString()).toBe('/pattern/gim');
});
});
});
});

0 comments on commit ce03328

Please sign in to comment.