Ensure _.camelCase handles acronyms and numbers.

This commit is contained in:
John-David Dalton
2014-03-27 09:22:17 -07:00
parent 07f1a13cbf
commit e5697a8070
2 changed files with 37 additions and 3 deletions

View File

@@ -1025,6 +1025,12 @@
});
});
test('`_.' + methodName + '` should handle double-converting strings', 4, function() {
_.forEach(['Hello world', 'helloWorld', '--hello-world', '__hello_world__'], function(string) {
equal(func(func(string)), expected);
});
});
test('`_.' + methodName + '` should deburr letters', 1, function() {
var actual = _.map(burredLetters, function(burred, index) {
var isCamel = caseName == 'camel',
@@ -1059,6 +1065,25 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.camelCase');
(function() {
test('should work with numbers', 6, function() {
equal(_.camelCase('P2P'), 'p2p');
equal(_.camelCase('ascii 2 unicode'), 'ascii2unicode');
equal(_.camelCase('two 4 one'), 'two4one');
equal(_.camelCase('walk 500 miles'), 'walk500Miles');
equal(_.camelCase('xhr2 request'), 'xhr2Request');
equal(_.camelCase('too legit 2 quit'), 'tooLegit2Quit');
});
test('should handle acronyms', 1, function() {
equal(_.camelCase('XMLHttpRequest'), 'xmlHttpRequest');
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.capitalize');
(function() {