Add split and replace to LodashWrapper. [closes #1016]

This commit is contained in:
octref
2015-03-06 21:52:10 -05:00
committed by jdalton
parent 135bc2de52
commit eb1b7b914a
2 changed files with 74 additions and 11 deletions

View File

@@ -15653,6 +15653,25 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...).replace');
(function() {
test('should support string replace', 2, function() {
if (!isNpm) {
var string = 'hi hidash',
wrapped = _(string);
deepEqual(wrapped.replace('hi', 'lo').value(), 'lo hidash');
deepEqual(wrapped.replace(/hi/g, 'lo').value(), 'lo lodash');
}
else {
skipTest(2);
}
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...).reverse');
(function() {
@@ -15822,6 +15841,40 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...).split');
(function() {
test('should support string split', 1, function() {
if (!isNpm) {
var string = 'hi ya',
wrapped = _(string),
actual = ['hi', 'ya'];
deepEqual(wrapped.split(' ').value(), actual);
}
else {
skipTest(1);
}
});
}());
(function() {
test('should allow mixed string and array prototype methods', 1, function() {
if (!isNpm) {
var string = 'hi ya',
wrapped = _(string),
actual = 'hi,ya';
deepEqual(wrapped.split(' ').join(','), actual);
}
else {
skipTest(1);
}
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...).unshift');
(function() {