|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | import assert from 'node:assert/strict';
|
| 7 | +import { format } from 'node:util'; |
7 | 8 |
|
8 | 9 | import dotnetIdentifierCase from '../index.js';
|
9 | 10 |
|
10 |
| -describe('dotnetIdentifierCase', () => { |
11 |
| - it('returns empty string unchanged', () => { |
12 |
| - assert.equal(dotnetIdentifierCase(''), ''); |
13 |
| - }); |
14 |
| - |
15 |
| - it('converts undefined to "Undefined"', () => { |
16 |
| - assert.equal(dotnetIdentifierCase(), 'Undefined'); |
17 |
| - }); |
18 |
| - |
19 |
| - it('converts 1 to "1"', () => { |
20 |
| - assert.equal(dotnetIdentifierCase(1), '1'); |
21 |
| - }); |
22 |
| - |
23 |
| - it('converts "foo" to "foo"', () => { |
24 |
| - assert.equal(dotnetIdentifierCase('foo'), 'Foo'); |
| 11 | +function itTransforms(from, to) { |
| 12 | + it(format('transforms %j to %j', from, to), () => { |
| 13 | + assert.equal(dotnetIdentifierCase(from), to); |
25 | 14 | });
|
| 15 | +} |
26 | 16 |
|
27 |
| - it('converts "Foo" to "foo"', () => { |
28 |
| - assert.equal(dotnetIdentifierCase('Foo'), 'Foo'); |
29 |
| - }); |
30 |
| - |
31 |
| - it('converts "fOo" to "foo"', () => { |
32 |
| - assert.equal(dotnetIdentifierCase('fOo'), 'FOo'); |
33 |
| - }); |
34 |
| - |
35 |
| - it('converts "FOO" to "foo"', () => { |
36 |
| - assert.equal(dotnetIdentifierCase('FOO'), 'Foo'); |
37 |
| - }); |
38 |
| - |
39 |
| - it('converts "foo bar" to "FooBar"', () => { |
40 |
| - assert.equal(dotnetIdentifierCase('foo bar'), 'FooBar'); |
41 |
| - }); |
| 17 | +describe('dotnetIdentifierCase', () => { |
| 18 | + itTransforms('', ''); |
| 19 | + itTransforms(undefined, 'Undefined'); |
| 20 | + itTransforms(1, '1'); |
| 21 | + itTransforms('foo', 'Foo'); |
| 22 | + itTransforms('Foo', 'Foo'); |
| 23 | + itTransforms('fOo', 'FOo'); |
| 24 | + itTransforms('FOO', 'Foo'); |
| 25 | + itTransforms(' foo ', 'Foo'); |
| 26 | + itTransforms('_foo_', 'Foo'); |
| 27 | + itTransforms('foo bar', 'FooBar'); |
| 28 | + itTransforms('foo_bar', 'FooBar'); |
| 29 | + itTransforms('foo.bar', 'FooBar'); |
| 30 | + itTransforms('foo-bar', 'FooBar'); |
| 31 | + itTransforms('fooBar', 'FooBar'); |
| 32 | + itTransforms("foo's", 'Foos'); |
| 33 | + itTransforms('fooV2', 'FooV2'); |
42 | 34 | });
|
0 commit comments