Skip to content

Commit

Permalink
feat(#6): Add display name
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrea committed Jan 12, 2020
1 parent e9bf2ea commit f615b41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.3.0] - 2020-01-12
### Added
- Add display name

## [1.2.1] - 2020-01-12
### Changed
Expand Down
6 changes: 6 additions & 0 deletions src/Inquirer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const inquirer = require("inquirer");
const autocomplete = require("inquirer-autocomplete-prompt");
const { cloneDeep, map } = require("lodash");

const packageInfo = require("../package.json");

inquirer.registerPrompt("autocomplete", autocomplete);

const STDIN_ENCODING = "utf8";
Expand All @@ -37,6 +39,10 @@ const Inquirer = class Inquirer {
this._exitLogsMode = this._exitLogsMode.bind(this);
}

get displayName() {
return packageInfo.name;
}

_initQuestions(questions, quitMethod) {
const clonedQuestions = cloneDeep(questions);
const quitQuestion = {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/src/Inquirer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ describe("Inquirer", () => {
sandbox.restore();
});

describe("display name", () => {
it("should return package name", async () => {
const cli = new Inquirer(fooQuestions);
expect(cli.displayName).toEqual("@mocks-server/plugin-inquirer-cli");
});
});

describe("when initing questions", () => {
it("should add an extra exit option to main menu", () => {
const cli = new Inquirer(fooQuestions);
Expand Down

0 comments on commit f615b41

Please sign in to comment.