mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-07 23:03:11 +08:00
Properly handle promise in create script (#784)
* Properly handle promise in create script * Add regression test
This commit is contained in:
parent
997943a194
commit
1de7c38134
@ -272,7 +272,7 @@ exports.create = function (project_path, config, options, events) {
|
|||||||
// Make the package conform to Java package types
|
// Make the package conform to Java package types
|
||||||
return exports.validatePackageName(package_name)
|
return exports.validatePackageName(package_name)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
exports.validateProjectName(project_name);
|
return exports.validateProjectName(project_name);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
// Log the given values for the project
|
// Log the given values for the project
|
||||||
events.emit('log', 'Creating Cordova project for the Android platform:');
|
events.emit('log', 'Creating Cordova project for the Android platform:');
|
||||||
|
@ -213,6 +213,17 @@ describe('create', function () {
|
|||||||
expect(err.message).toContain('Project already exists!');
|
expect(err.message).toContain('Project already exists!');
|
||||||
}).done(done);
|
}).done(done);
|
||||||
});
|
});
|
||||||
|
it('should fail if validateProjectName rejects', () => {
|
||||||
|
const fakeError = new Error();
|
||||||
|
create.validateProjectName.and.callFake(() => Promise.reject(fakeError));
|
||||||
|
|
||||||
|
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
||||||
|
fail('Expected promise to be rejected');
|
||||||
|
}, err => {
|
||||||
|
expect(err).toBe(fakeError);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('happy path', function () {
|
describe('happy path', function () {
|
||||||
it('should copy project templates from a specified custom template', function (done) {
|
it('should copy project templates from a specified custom template', function (done) {
|
||||||
|
Loading…
Reference in New Issue
Block a user