Skip to content

Commit

Permalink
refactor: transform arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Apr 16, 2020
1 parent 950abb5 commit 96fe917
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function cordovaCreate (dest, opts = {}) {
// TODO this is to avoid having a huge diff. Remove later.
let dir = dest;

return Promise.resolve().then(function () {
return Promise.resolve().then(() => {
if (!dir) {
throw new CordovaError('Directory not specified. See `cordova help`.');
}
Expand Down Expand Up @@ -80,7 +80,7 @@ function cordovaCreate (dest, opts = {}) {
);
}
})
.then(function () {
.then(() => {
// Finally, Ready to start!
emit('log', 'Creating a new cordova project.');

Expand All @@ -94,7 +94,7 @@ function cordovaCreate (dest, opts = {}) {
return path.resolve(opts.template);
}
})
.then(function (templatePath) {
.then(templatePath => {
let import_from_path;

try {
Expand Down
38 changes: 19 additions & 19 deletions spec/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@ const project = path.join(tmpDir, appName);

let opts;

beforeEach(function () {
beforeEach(() => {
fs.emptyDirSync(tmpDir);
opts = { name: appName, id: appId };
});
afterAll(function () {
afterAll(() => {
process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows.
fs.removeSync(tmpDir);
});

describe('cordova create checks for valid-identifier', function () {
describe('cordova create checks for valid-identifier', () => {
const error = new CordovaError('is not a valid identifier');

it('should reject reserved words from start of id', function () {
it('should reject reserved words from start of id', () => {
opts.id = 'int.bob';
return expectRejection(create(project, opts), error);
});

it('should reject reserved words from end of id', function () {
it('should reject reserved words from end of id', () => {
opts.id = 'bob.class';
return expectRejection(create(project, opts), error);
});
});

describe('create end-to-end', function () {
describe('create end-to-end', () => {
function checkCommonArtifacts () {
// Check that www dir exist
expect(path.join(project, 'www')).toExist();
Expand Down Expand Up @@ -116,14 +116,14 @@ describe('create end-to-end', function () {
checkDefaultTemplate();
}

it('should successfully run without template and use default hello-world app', function () {
it('should successfully run without template and use default hello-world app', () => {
// Create a real project with no template
// use default cordova-app-hello-world app
return create(project, opts)
.then(checkProjectCreatedWithDefaultTemplate);
});

it('should successfully run with Git URL', function () {
it('should successfully run with Git URL', () => {
// Create a real project with git URL as template
opts.template = 'https://github.com/apache/cordova-app-hello-world';
return createWithMockFetch(project, opts)
Expand All @@ -134,7 +134,7 @@ describe('create end-to-end', function () {
.then(checkProjectCreatedWithDefaultTemplate);
});

it('should successfully run with NPM package (specific version)', function () {
it('should successfully run with NPM package (specific version)', () => {
// Create a real project with npm module as template
opts.template = 'phonegap-template-vue-f7-tabs@1';
return createWithMockFetch(project, opts)
Expand All @@ -145,7 +145,7 @@ describe('create end-to-end', function () {
.then(checkProjectCreatedWithDefaultTemplate);
});

it('should successfully run with NPM package (no specific version)', function () {
it('should successfully run with NPM package (no specific version)', () => {
// Create a real project with npm module as template
opts.template = 'phonegap-template-vue-f7-tabs';
return createWithMockFetch(project, opts)
Expand All @@ -156,23 +156,23 @@ describe('create end-to-end', function () {
.then(checkProjectCreatedWithDefaultTemplate);
});

it('should successfully run with local template having no package.json in template dir', function () {
it('should successfully run with local template having no package.json in template dir', () => {
opts.template = path.join(__dirname, 'templates/withsubdirectory');
return create(project, opts)
.then(checkCommonArtifacts)
.then(checkNoPackageJson)
.then(checkNotDefaultTemplate);
});

it('should successfully run with local template having package.json in template dir', function () {
it('should successfully run with local template having package.json in template dir', () => {
opts.template = path.join(__dirname, 'templates/withsubdirectory_package_json');
return create(project, opts)
.then(checkCommonArtifacts)
.then(checkPackageJson)
.then(checkNotDefaultTemplate);
});

it('should successfully run with existing, empty destination', function () {
it('should successfully run with existing, empty destination', () => {
fs.ensureDirSync(project);
return create(project, opts)
.then(checkProjectCreatedWithDefaultTemplate);
Expand Down Expand Up @@ -206,30 +206,30 @@ describe('create end-to-end', function () {
});
});

describe('when shit happens', function () {
it('should fail when dir is missing', function () {
describe('when shit happens', () => {
it('should fail when dir is missing', () => {
return expectRejection(
create(null, opts),
new CordovaError('Directory not specified')
);
});

it('should fail when dir already exists', function () {
it('should fail when dir already exists', () => {
return expectRejection(
create(__dirname, opts),
new CordovaError('Path already exists and is not empty')
);
});

it('should fail when destination is inside template', function () {
it('should fail when destination is inside template', () => {
opts.template = path.join(tmpDir, 'template');
return expectRejection(
create(path.join(opts.template, 'destination'), opts),
new CordovaError('inside the template')
);
});

it('should fail when fetch fails', function () {
it('should fail when fetch fails', () => {
const fetchError = new Error('Fetch fail');
const failingFetch = jasmine.createSpy('failingFetch')
.and.callFake(() => Promise.reject(fetchError));
Expand All @@ -242,7 +242,7 @@ describe('when shit happens', function () {
});

// FIXME: we need to improve isRemote to make this different from the test above
xit('should fail when template does not exist', function () {
xit('should fail when template does not exist', () => {
opts.template = path.join(__dirname, 'doesnotexist');
return expectRejection(
create(project, opts),
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = {
};

// Add the toExist matcher.
beforeEach(function () {
beforeEach(() => {
jasmine.addMatchers({
toExist: function () {
return {
Expand Down

0 comments on commit 96fe917

Please sign in to comment.