mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
Ensure string case methods work with words in all caps.
This commit is contained in:
@@ -102,7 +102,7 @@
|
|||||||
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
||||||
|
|
||||||
/** Used to match words to create compound words */
|
/** Used to match words to create compound words */
|
||||||
var reWords = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
var reWords = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]+|[0-9]+/g;
|
||||||
|
|
||||||
/** Used to detect and test whitespace */
|
/** Used to detect and test whitespace */
|
||||||
var whitespace = (
|
var whitespace = (
|
||||||
|
|||||||
10
test/test.js
10
test/test.js
@@ -1286,7 +1286,8 @@
|
|||||||
|
|
||||||
_.each(['camel', 'kebab', 'snake'], function(caseName) {
|
_.each(['camel', 'kebab', 'snake'], function(caseName) {
|
||||||
var methodName = caseName + 'Case',
|
var methodName = caseName + 'Case',
|
||||||
func = _[methodName];
|
func = _[methodName],
|
||||||
|
isCamel = caseName == 'camel';
|
||||||
|
|
||||||
var expected = (function() {
|
var expected = (function() {
|
||||||
switch (caseName) {
|
switch (caseName) {
|
||||||
@@ -1322,10 +1323,13 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('`_.' + methodName + '` should work with words in all caps', 1, function() {
|
||||||
|
strictEqual(func('HELLO WORLD'), isCamel ? 'helloWORLD' : expected);
|
||||||
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should deburr letters', 1, function() {
|
test('`_.' + methodName + '` should deburr letters', 1, function() {
|
||||||
var actual = _.map(burredLetters, function(burred, index) {
|
var actual = _.map(burredLetters, function(burred, index) {
|
||||||
var isCamel = caseName == 'camel',
|
var deburrLetter = deburredLetters[index];
|
||||||
deburrLetter = deburredLetters[index];
|
|
||||||
|
|
||||||
var string = isCamel
|
var string = isCamel
|
||||||
? func('z' + burred)
|
? func('z' + burred)
|
||||||
|
|||||||
Reference in New Issue
Block a user