Skip to content

Commit

Permalink
Add prompt message utility to base command (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
childish-sambino authored and dprothero committed Jul 31, 2019
1 parent cb0f46b commit 15db53c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/base-commands/base-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class BaseCommand extends Command {

return limitedData;
}

getPromptMessage(message) {
// Drop the trailing period and put a colon at the end of the message.
return message.trim().replace(/[.:]?$/, ':');
}
}

BaseCommand.flags = {
Expand Down
8 changes: 8 additions & 0 deletions test/base-commands/base-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,13 @@ describe('base-commands', () => {
expect(ctx.stdout).to.contain('FOO\tBAR\nfoo\tbar\n2\t2');
});
});

describe('getPromptMessage', () => {
baseCommandTest.it('adds a colon to the end of the message', ctx => {
expect(ctx.testCmd.getPromptMessage('Name: ')).to.equal('Name:');
expect(ctx.testCmd.getPromptMessage('Number.')).to.equal('Number:');
expect(ctx.testCmd.getPromptMessage(' Address ')).to.equal('Address:');
});
});
});
});

0 comments on commit 15db53c

Please sign in to comment.