diff --git a/src/commands/new/glee.ts b/src/commands/new/glee.ts index 96ee27b5fc5..1df10309735 100644 --- a/src/commands/new/glee.ts +++ b/src/commands/new/glee.ts @@ -11,7 +11,7 @@ import { prompt } from 'inquirer'; import Generator from '@asyncapi/generator'; import { green, gray } from 'picocolors'; -const successMessage = (projectName: string) => +export const successMessage = (projectName: string) => `🎉 Your glee project "${green(projectName)}" has been successfully created! ⏩ Next steps: follow the instructions ${green('below')} to manage your project: @@ -27,8 +27,7 @@ const errorMessages = { `Unable to create the project because the directory "${green(projectName)}" already exists at "${process.cwd()}/${projectName}". To specify a different name for the new project, please run the command ${green('below')} with a unique project name: - ${gray('asyncapi new glee --name ${projectName}-1')} -`, + ${gray('asyncapi new glee --name ') + gray(projectName) + gray('-1')}`, }; export default class NewGlee extends Command { diff --git a/test/integration/new/file.test.ts b/test/integration/new/file.test.ts index 2fe078a860c..d957857d49f 100644 --- a/test/integration/new/file.test.ts +++ b/test/integration/new/file.test.ts @@ -26,7 +26,7 @@ describe('new', () => { .command(['new', '--no-tty', '-n=specification.yaml']) .it('runs new command', async (ctx,done) => { expect(ctx.stderr).to.equal(''); - expect(ctx.stdout).to.equal('Created file specification.yaml...\n'); + expect(ctx.stdout).to.equal('The specification.yaml has been successfully created.\n'); done(); }); @@ -36,7 +36,7 @@ describe('new', () => { .command(['new:file', '--no-tty', '-n=specification.yaml']) .it('runs new file command', async (ctx,done) => { expect(ctx.stderr).to.equal(''); - expect(ctx.stdout).to.equal('Created file specification.yaml...\n'); + expect(ctx.stdout).to.equal('The specification.yaml has been successfully created.\n'); done(); }); }); @@ -62,7 +62,7 @@ describe('new', () => { .command(['new:file', '--no-tty', '-n=specification.yaml']) .it('should inform about the existing file and finish the process', async (ctx,done) => { expect(ctx.stderr).to.equal(''); - expect(ctx.stdout).to.equal('File specification.yaml already exists. Ignoring...\n'); + expect(ctx.stdout).to.equal('A file named specification.yaml already exists. Please choose a different name.\n'); done(); }); }); diff --git a/test/integration/new/glee.test.ts b/test/integration/new/glee.test.ts index 82a7f6587fb..d92e46fc781 100644 --- a/test/integration/new/glee.test.ts +++ b/test/integration/new/glee.test.ts @@ -4,6 +4,17 @@ import { PROJECT_DIRECTORY_PATH } from '../../helpers'; import { expect } from '@oclif/test'; const testHelper = new TestHelper(); +const successMessage = (projectName: string) => + `🎉 Your glee project "${projectName}" has been successfully created! +`; + +const errorMessages = { + alreadyExists: (projectName: string) => + `Unable to create the project because the directory "${projectName}" already exists at "${process.cwd()}/${projectName}". +To specify a different name for the new project, please run the command below with a unique project name: + + asyncapi new glee --name ${projectName}-1`, +}; describe('new glee', () => { before(() => { @@ -27,7 +38,7 @@ describe('new glee', () => { .command(['new:glee', '-n=test-project']) .it('runs new glee command with name flag', async (ctx,done) => { expect(ctx.stderr).to.equal(''); - expect(ctx.stdout).to.equal('Your project "test-project" has been created successfully!\n\nNext steps:\n\n cd test-project\n npm install\n npm run dev\n\nAlso, you can already open the project in your favorite editor and start tweaking it.\n'); + expect(ctx.stdout).to.contain(successMessage('test-project')); done(); }); }); @@ -52,7 +63,7 @@ describe('new glee', () => { .stdout() .command(['new:glee', '-n=test-project']) .it('should throw error if name of the new project already exists', async (ctx,done) => { - expect(ctx.stderr).to.equal(`Error: Unable to create the project. We tried to use "test-project" as the directory of your new project but it already exists (${PROJECT_DIRECTORY_PATH}). Please specify a different name for the new project. For example, run the following command instead:\n\n asyncapi new glee --name test-project-1\n\n`); + expect(ctx.stderr).to.contains(`Error: ${errorMessages.alreadyExists('test-project')}`); expect(ctx.stdout).to.equal(''); done(); });