Skip to content

Commit

Permalink
test(charCase): add tests for case functions
Browse files Browse the repository at this point in the history
  • Loading branch information
0x04 committed Sep 2, 2020
1 parent 0b0f78a commit 45e5ad9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/_testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const stringLower = 'hello world!';

export const stringUpper = 'HELLO WORLD!';

export const stringCapitalized = 'Hello World!';

export const stringShort = 'How much wood would a wood chuck '
+ 'if a wood chuck could chuck wood.';

Expand Down
25 changes: 25 additions & 0 deletions test/char-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,28 @@ test('invert: undefined argument `string`', t =>
() => charCase.invert(undefined)
)
);

const caseFns = new Map();

caseFns.set('hello_world!', charCase.snakeCase);
caseFns.set('helloWorld!', charCase.camelCase);
caseFns.set('hello-world!', charCase.kebabCase);
caseFns.set('hello.world!', charCase.dotCase);
caseFns.set('HelloWorld!', charCase.pascalCase);
caseFns.set('Hello World!', charCase.capitalize);

const caseTestData = new Map();

caseTestData.set('stringLower', testData.stringLower);
// FIXME: That isn't a trivial problem as it seems at first
// caseTestData.set('stringUpper', testData.stringUpper);
caseTestData.set('stringCapitalized', testData.stringCapitalized);

caseFns.forEach((fn, resultString) =>
caseTestData.forEach((testString, testName) =>
test(`${fn.name}: ${testName}`, t => t.is(
fn(testString),
resultString
))
)
);

0 comments on commit 45e5ad9

Please sign in to comment.