Example #1
0
 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');
 });
Example #2
0
 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();
   });
 });
Example #3
0
 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'"
   );
 });
Example #4
0
 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]')
   );
 });
Example #5
0
 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'
     )
   );
 });
Example #6
0
 test('returns undefined for unknown blueprint', () => {
   const actualCommand = helpers.getBlueprintCommand('no_idea');
   expect(buildBlueprintCommands).toHaveBeenCalled();
   expect(actualCommand).toBe(undefined);
 });
Example #7
0
 test('returns existing command by alias', () => {
   const actualCommand = helpers.getBlueprintCommand('bp');
   expect(buildBlueprintCommands).toHaveBeenCalled();
   expect(actualCommand).toBe(blueprintCommand);
 });
Example #8
0
 test('returns array of blueprint commands', () => {
   const actualCommands = helpers.getBlueprintCommands();
   expect(buildBlueprintCommands).toHaveBeenCalled();
   expect(actualCommands).toBe(blueprintCommands);
 });