test('logs unknown blueprint', () => { const yargs = Yargs(); const helper = helpers.getBlueprintHelper(yargs, 'existential'); expect(helpers.logMissingBlueprint).toHaveBeenCalled(); expect(helpers.logMissingBlueprint.mock.calls[0][0]).toBe(yargs); expect(helpers.logMissingBlueprint.mock.calls[0][1]).toBe('existential'); });
test('returns runnable blueprint', done => { const yargs = Yargs(); const runner = helpers.getBlueprintRunner(yargs, 'blueprint'); expect(runner).toBe(yargs); runner.parse('blueprint testable', (err, argv, output) => { expect(blueprintCommand.handler).toHaveBeenCalled(); done(); }); });
test('logYargs unknown blueprint', () => { const yargs = {}; const blueprintName = 'i_am_missing'; helpers.logMissingBlueprint(yargs, blueprintName); expect(logYargs).toHaveBeenCalled(); expect(logYargs.mock.calls[0][0]).toBe(yargs); expect(logYargs.mock.calls[0][1]).toEqual( "Unknown blueprint 'i_am_missing'" ); });
test('builds help for blueprint', () => { const yargs = Yargs(); const helper = helpers.getBlueprintHelper(yargs, 'duck'); helper.showHelp(); expect(console.error).toHaveBeenCalled(); const help = console.error.mock.calls[0][0]; expect(help).toMatch(lineRegEx('Blueprint Options:')); expect(help).toMatch( lineRegEx('--types', 'Specify ACTION_TYPE constants', '[array]') ); });
test('builds help for all blueprint commands', () => { const yargs = Yargs(); const helper = helpers.getBlueprintListHelper(yargs); helper.showHelp(); expect(console.error).toHaveBeenCalled(); const help = console.error.mock.calls[0][0]; expect(help).toMatch(lineRegEx('Blueprints:')); expect(help).toMatch( lineRegEx( 'blueprint <name> [options]', 'Generate a blueprint with specified hooks', '[aliases: bp]' ) ); expect(help).toMatch( lineRegEx( 'duck <name> [options]', 'Generate a duck with types and action handlers' ) ); });
test('returns undefined for unknown blueprint', () => { const actualCommand = helpers.getBlueprintCommand('no_idea'); expect(buildBlueprintCommands).toHaveBeenCalled(); expect(actualCommand).toBe(undefined); });
test('returns existing command by alias', () => { const actualCommand = helpers.getBlueprintCommand('bp'); expect(buildBlueprintCommands).toHaveBeenCalled(); expect(actualCommand).toBe(blueprintCommand); });
test('returns array of blueprint commands', () => { const actualCommands = helpers.getBlueprintCommands(); expect(buildBlueprintCommands).toHaveBeenCalled(); expect(actualCommands).toBe(blueprintCommands); });