DefinitelyTyped/types/change-case-object/change-case-object-tests.ts
James Chao 7fce69ce62 Add types for change-case-object (#40791)
* Add types for change-case-object

* Changed return type to just arrays, not readonly

* Fixed issue with typing array params

* Updated tests
2019-12-16 14:06:59 +00:00

56 lines
1.7 KiB
TypeScript

import changeCaseObject = require('change-case-object');
// $ExpectType object
changeCaseObject.camelCase({ hello_world: 'hi' });
// $ExpectType string
changeCaseObject.camelCase('hello_world');
// $ExpectType string[]
changeCaseObject.camelCase(['hello_world']);
// $ExpectType object[]
changeCaseObject.camelCase([{ hello_world: 'hi' }]);
// $ExpectType object
changeCaseObject.snakeCase({ helloWorld: 'hi' });
// $ExpectType string
changeCaseObject.snakeCase('helloWorld');
// $ExpectType string[]
changeCaseObject.snakeCase(['helloWorld']);
// $ExpectType object[]
changeCaseObject.snakeCase([{ hello_world: 'hi' }]);
// $ExpectType object
changeCaseObject.paramCase({ helloWorld: 'hi' });
// $ExpectType string
changeCaseObject.paramCase('helloWorld');
// $ExpectType string[]
changeCaseObject.paramCase(['helloWorld']);
// $ExpectType object[]
changeCaseObject.paramCase([{ hello_world: 'hi' }]);
// $ExpectType object
changeCaseObject.camel({ hello_world: 'hi' });
// $ExpectType string
changeCaseObject.camel('hello_world');
// $ExpectType string[]
changeCaseObject.camel(['hello_world']);
// $ExpectType object[]
changeCaseObject.camel([{ hello_world: 'hi' }]);
// $ExpectType object
changeCaseObject.snake({ helloWorld: 'hi' });
// $ExpectType string
changeCaseObject.snake('helloWorld');
// $ExpectType string[]
changeCaseObject.snake(['helloWorld']);
// $ExpectType object[]
changeCaseObject.snake([{ hello_world: 'hi' }]);
// $ExpectType object
changeCaseObject.param({ helloWorld: 'hi' });
// $ExpectType string
changeCaseObject.param('helloWorld');
// $ExpectType string[]
changeCaseObject.param(['helloWorld']);
// $ExpectType object[]
changeCaseObject.param([{ hello_world: 'hi' }]);