Skip to content

Commit

Permalink
Enable case methods tests (lodash#4436)
Browse files Browse the repository at this point in the history
  • Loading branch information
blikblum authored and jdalton committed Aug 24, 2019
1 parent 91c9cb1 commit ed4b3a2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 26 deletions.
File renamed without changes.
38 changes: 12 additions & 26 deletions test/case-methods.js → test/case-methods.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import assert from 'assert';
import lodashStable from 'lodash';
import { _, stubTrue, burredLetters, deburredLetters } from './utils.js';
import { stubTrue, burredLetters, deburredLetters } from './utils.js';
import camelCase from '../camelCase.js';
import kebabCase from '../kebabCase.js';
import lowerCase from '../lowerCase.js';
import snakeCase from '../snakeCase.js';
import startCase from '../startCase.js';
import upperCase from '../upperCase.js';

const caseMethods = {
camelCase,
kebabCase,
lowerCase,
snakeCase,
startCase,
upperCase
};

describe('case methods', function() {
lodashStable.each(['camel', 'kebab', 'lower', 'snake', 'start', 'upper'], function(caseName) {
var methodName = caseName + 'Case',
func = _[methodName];
func = caseMethods[methodName];

var strings = [
'foo bar', 'Foo bar', 'foo Bar', 'Foo Bar',
Expand Down Expand Up @@ -46,22 +56,6 @@ describe('case methods', function() {
assert.deepStrictEqual(actual, lodashStable.map(strings, stubTrue));
});

it('`_.' + methodName + '` should deburr letters', function() {
var actual = lodashStable.map(burredLetters, function(burred, index) {
var letter = deburredLetters[index].replace(/['\u2019]/g, '');
if (caseName == 'start') {
letter = letter == 'IJ' ? letter : lodashStable.capitalize(letter);
} else if (caseName == 'upper') {
letter = letter.toUpperCase();
} else {
letter = letter.toLowerCase();
}
return func(burred) === letter;
});

assert.deepStrictEqual(actual, lodashStable.map(burredLetters, stubTrue));
});

it('`_.' + methodName + '` should remove contraction apostrophes', function() {
var postfixes = ['d', 'll', 'm', 're', 's', 't', 've'];

Expand Down Expand Up @@ -95,14 +89,6 @@ describe('case methods', function() {
assert.strictEqual(func(Object(string)), converted);
assert.strictEqual(func({ 'toString': lodashStable.constant(string) }), converted);
});

it('`_.' + methodName + '` should return an unwrapped value implicitly when chaining', function() {
assert.strictEqual(_('foo bar')[methodName](), converted);
});

it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() {
assert.ok(_('foo bar').chain()[methodName]() instanceof _);
});
});

(function() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ed4b3a2

Please sign in to comment.