-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from ComponentDriven/norbert/fix-startcase
Improve the startcase implementation to mimick lodash's version more closely
- Loading branch information
Showing
4 changed files
with
677 additions
and
654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
/* eslint-disable eslint-comments/disable-enable-pair */ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import startCase from 'lodash/startCase'; | ||
import { toStartCaseStr } from './toStartCaseStr'; | ||
|
||
test.each([ | ||
['snake_case', 'Snake Case'], | ||
['AAAaaaAAAaaa', 'AA Aaaa AA Aaaa'], | ||
['kebab-case', 'Kebab Case'], | ||
['camelCase', 'Camel Case'], | ||
['camelCase1', 'Camel Case 1'], | ||
['camelCase1a', 'Camel Case 1a'], | ||
['camelCase1A', 'Camel Case 1A'], | ||
['camelCase1A2', 'Camel Case 1A 2'], | ||
['camelCase1A2b', 'Camel Case 1A 2b'], | ||
['camelCase1A2B', 'Camel Case 1A 2B'], | ||
['camelCase1A2B3', 'Camel Case 1A 2B 3'], | ||
['camelCase1a', 'Camel Case 1 A'], | ||
['camelCase1A', 'Camel Case 1 A'], | ||
['camelCase1A2', 'Camel Case 1 A 2'], | ||
['camelCase1A2b', 'Camel Case 1 A 2 B'], | ||
['camelCase1A2B', 'Camel Case 1 A 2 B'], | ||
['camelCase1A2B3', 'Camel Case 1 A 2 B 3'], | ||
['__FOOBAR__', 'FOOBAR'], | ||
['__FOO_BAR__', 'FOO BAR'], | ||
['__FOO__BAR__', 'FOO BAR'], | ||
[' FOO BAR', 'FOO BAR'], | ||
['1. Fooo', '1. Fooo'], | ||
['1. Fooo', '1 Fooo'], | ||
['ZIndex', 'Z Index'], | ||
])('%s', (str, expected) => { | ||
expect(toStartCaseStr(str)).toBe(expected); | ||
const outcome = toStartCaseStr(str); | ||
const fromLodash = startCase(str); | ||
|
||
expect({ outcome, fromLodash }).toEqual({ | ||
outcome: expected, | ||
fromLodash, | ||
}); | ||
expect(outcome).toEqual(fromLodash); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.