Skip to content

Commit

Permalink
Make string tests more consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 17, 2016
1 parent d9dc0e6 commit 664d66a
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2591,27 +2591,6 @@
}
});

QUnit.test('`_.' + methodName + '` should clone `index` and `input` array properties', function(assert) {
assert.expect(2);

var array = /x/.exec('vwxyz'),
actual = func(array);

assert.strictEqual(actual.index, 2);
assert.strictEqual(actual.input, 'vwxyz');
});

QUnit.test('`_.' + methodName + '` should clone `lastIndex` regexp property', function(assert) {
assert.expect(1);

// Avoid a regexp literal for older Opera and use `exec` for older Safari.
var regexp = RegExp('x', 'g');
regexp.exec('vwxyz');

var actual = func(regexp);
assert.strictEqual(actual.lastIndex, 3);
});

QUnit.test('`_.' + methodName + '` should clone buffers', function(assert) {
assert.expect(4);

Expand All @@ -2631,6 +2610,28 @@
}
});

QUnit.test('`_.' + methodName + '` should clone `index` and `input` array properties', function(assert) {
assert.expect(2);

var array = /c/.exec('abcde'),
actual = func(array);

assert.strictEqual(actual.index, 2);
assert.strictEqual(actual.input, 'abcde');
});

QUnit.test('`_.' + methodName + '` should clone `lastIndex` regexp property', function(assert) {
assert.expect(1);

// Avoid a regexp literal for older Opera and use `exec` for older Safari.
var regexp = RegExp('c', 'g');

regexp.exec('abcde');

var actual = func(regexp);
assert.strictEqual(actual.lastIndex, 3);
});

QUnit.test('`_.' + methodName + '` should clone prototype objects', function(assert) {
assert.expect(2);

Expand Down Expand Up @@ -8543,8 +8544,8 @@

assert.strictEqual(_.isEqual(array1, array2), true);

array1 = /x/.exec('vwxyz');
array2 = ['x'];
array1 = /c/.exec('abcde');
array2 = ['c'];

assert.strictEqual(_.isEqual(array1, array2), true);
});
Expand Down Expand Up @@ -14121,7 +14122,7 @@
QUnit.test('should not convert strings to arrays when merging arrays of `source`', function(assert) {
assert.expect(1);

var object = { 'a': 'abcdef' },
var object = { 'a': 'abcde' },
actual = _.merge(object, { 'a': ['x', 'y', 'z'] });

assert.deepEqual(actual, { 'a': ['x', 'y', 'z'] });
Expand Down Expand Up @@ -17542,9 +17543,9 @@
QUnit.test('should replace the matched pattern', function(assert) {
assert.expect(2);

var string = 'abcdef';
assert.strictEqual(_.replace(string, 'def', '123'), 'abc123');
assert.strictEqual(_.replace(string, /[bdf]/g, '-'), 'a-c-e-');
var string = 'abcde';
assert.strictEqual(_.replace(string, 'de', '123'), 'abc123');
assert.strictEqual(_.replace(string, /[bd]/g, '-'), 'a-c-e');
});
}());

Expand Down

0 comments on commit 664d66a

Please # to comment.