UNPKG

api-client-generator

Version:

Angular REST API client generator from Swagger YAML or JSON file with camel case settings

48 lines 2.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var helper_1 = require("./helper"); describe('[helpers] to camelCase', function () { it('should convert dash to camelCase', function () { expect(helper_1.toCamelCase('some-service')).toEqual('someService'); expect(helper_1.toCamelCase('some-really-long-service')).toEqual('someReallyLongService'); expect(helper_1.toCamelCase('a42-wololo')).toEqual('a42Wololo'); expect(helper_1.toCamelCase('--param')).toEqual('param'); }); it('should convert some separators to camelCase', function () { expect(helper_1.toCamelCase('folder/some_really-long.service')).toEqual('folderSomeReallyLongService'); }); it('should convert to camelCase and capitalize firs letter', function () { expect(helper_1.toCamelCase('my-awesome.model', false)).toEqual('MyAwesomeModel'); }); }); describe('[helpers] remove duplicate words', function () { it('should remove duplicates in sentence', function () { expect(helper_1.removeDuplicateWords('modelmodel')).toEqual('model'); expect(helper_1.removeDuplicateWords('UserModelModel')).toEqual('UserModel'); expect(helper_1.removeDuplicateWords('shipmentShipmentAddress')).toEqual('ShipmentAddress'); expect(helper_1.removeDuplicateWords('idWololoID')).toEqual('idWololoID'); expect(helper_1.removeDuplicateWords('UrlichUrl')).toEqual('UrlichUrl'); }); }); describe('[helpers] determine TS type', function () { it('should detect build-in types', function () { expect(helper_1.toTypescriptType('integer')).toEqual('number'); expect(helper_1.toTypescriptType('Integer')).toEqual('number'); expect(helper_1.toTypescriptType('double')).toEqual('number'); expect(helper_1.toTypescriptType('number')).toEqual('number'); expect(helper_1.toTypescriptType('string')).toEqual('string'); expect(helper_1.toTypescriptType('boolean')).toEqual('boolean'); expect(helper_1.toTypescriptType('Boolean')).toEqual('boolean'); expect(helper_1.toTypescriptType('object')).toEqual('object'); expect(helper_1.toTypescriptType('Object')).toEqual('object'); expect(helper_1.toTypescriptType('array')).toEqual('any[]'); expect(helper_1.toTypescriptType('Array')).toEqual('any[]'); }); it('should NOT replace type by build-in types', function () { expect(helper_1.toTypescriptType('modelInteger')).toEqual('ModelInteger'); expect(helper_1.toTypescriptType('MyString')).toEqual('MyString'); expect(helper_1.toTypescriptType('stringValue')).toEqual('StringValue'); expect(helper_1.toTypescriptType('Bool')).toEqual('Bool'); }); }); //# sourceMappingURL=helpers.tests.js.map