UNPKG

@yolkai/nx-tao

Version:

CLI for generating code and running commands

96 lines (95 loc) 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const params_1 = require("./params"); describe('params', () => { describe('convertToCamelCase', () => { it('should convert dash case to camel case', () => { expect(params_1.convertToCamelCase({ 'one-two': 1 })).toEqual({ oneTwo: 1 }); }); it('should not convert camel case', () => { expect(params_1.convertToCamelCase({ oneTwo: 1 })).toEqual({ oneTwo: 1 }); }); it('should handle mixed case', () => { expect(params_1.convertToCamelCase({ 'one-Two': 1 })).toEqual({ oneTwo: 1 }); }); }); describe('convertAliases', () => { it('should replace aliases with actual keys', () => { expect(params_1.convertAliases({ d: 'test' }, { properties: { directory: { type: 'string', alias: 'd' } }, required: [], description: '' })).toEqual({ directory: 'test' }); }); it('should filter unknown keys into the leftovers field', () => { expect(params_1.convertAliases({ d: 'test' }, { properties: { directory: { type: 'string' } }, required: [], description: '' })).toEqual({ '--': [ { name: 'd', possible: [] } ] }); }); }); describe('lookupUnmatched', () => { it('should populate the possible array with near matches', () => { expect(params_1.lookupUnmatched({ '--': [ { name: 'directoy', possible: [] } ] }, { properties: { directory: { type: 'string' } }, required: [], description: '' })).toEqual({ '--': [ { name: 'directoy', possible: ['directory'] } ] }); }); it('should NOT populate the possible array with far matches', () => { expect(params_1.lookupUnmatched({ '--': [ { name: 'directoy', possible: [] } ] }, { properties: { faraway: { type: 'string' } }, required: [], description: '' })).toEqual({ '--': [ { name: 'directoy', possible: [] } ] }); }); }); });