UNPKG

@cuba-platform/front-generator

Version:
33 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const cli_options_1 = require("../../common/cli-options"); const chai_1 = require("chai"); describe('cli options', function () { it('should return empty array if no options passed', function () { (0, chai_1.expect)((0, cli_options_1.extractAvailableOptions)().length).eq(0); }); it('should return empty array if alias not set', function () { const optsConfig = { option1: {} }; (0, chai_1.expect)((0, cli_options_1.extractAvailableOptions)(optsConfig).length).eq(0); }); it('should extract options from config', function () { const optionConfig = { alias: 'o1' }; const optsConfig = { option1: optionConfig }; let res = (0, cli_options_1.extractAvailableOptions)(optsConfig); (0, chai_1.expect)(res[0].pattern).eq('-o1, --option1'); (0, chai_1.expect)(res[0].description).to.be.undefined; optionConfig['description'] = 'option one'; res = (0, cli_options_1.extractAvailableOptions)(optsConfig); (0, chai_1.expect)(res[0].pattern).eq('-o1, --option1'); (0, chai_1.expect)(res[0].description).eq('option one'); }); it('should pick options from cmd', function () { const optionConfig = { alias: 'o1' }; const optsConfig = { option1: optionConfig }; let res = (0, cli_options_1.pickOptions)({ opt: 123 }, optsConfig); (0, chai_1.expect)(res).to.be.empty; res = (0, cli_options_1.pickOptions)({ option1: 123 }, optsConfig); (0, chai_1.expect)(res['option1']).eq(123); }); }); //# sourceMappingURL=cli-options.test.js.map