-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22d5325
commit f5d48f8
Showing
3 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { test } from '@oclif/test'; | ||
import TestHelper from '../../helpers'; | ||
import { expect } from '@oclif/test'; | ||
|
||
const testHelper = new TestHelper(); | ||
const successMessage = (projectName: string) => | ||
'🎉 Your template is succesfully 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:`}; | ||
|
||
describe('new template', () => { | ||
before(() => { | ||
try { | ||
testHelper.deleteDummyProjectDirectory(); | ||
} catch (e: any) { | ||
if (e.code !== 'ENOENT') { | ||
throw e; | ||
} | ||
} | ||
}); | ||
|
||
describe('creation of new project is successful', () => { | ||
afterEach(() => { | ||
testHelper.deleteDummyProjectDirectory(); | ||
}); | ||
|
||
test | ||
.stderr() | ||
.stdout() | ||
.command(['new:template', '-n=test-project']) | ||
.it('runs new template command with name flag', async (ctx,done) => { | ||
expect(ctx.stderr).to.equal(''); | ||
expect(ctx.stdout).to.contains(successMessage('test-project')); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('when new project name already exists', () => { | ||
beforeEach(() => { | ||
try { | ||
testHelper.createDummyProjectDirectory(); | ||
} catch (e: any) { | ||
if (e.code !== 'EEXIST') { | ||
throw e; | ||
} | ||
} | ||
}); | ||
|
||
afterEach(() => { | ||
testHelper.deleteDummyProjectDirectory(); | ||
}); | ||
|
||
test | ||
.stderr() | ||
.stdout() | ||
.command(['new:template', '-n=test-project']) | ||
.it('should throw error if name of the new project already exists', async (ctx,done) => { | ||
expect(ctx.stderr).to.contains(`Error: ${errorMessages.alreadyExists('test-project')}`); | ||
expect(ctx.stdout).to.equal(''); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|