fix(prettier): Properly handle lint-stage files (#6970)

Now handles top level files and recursive files in folders.

Set max line length to be 100
This commit is contained in:
Diamond Lewis
2020-10-25 15:06:58 -05:00
committed by GitHub
parent c2f2281e6d
commit e6ac3b6932
178 changed files with 5585 additions and 10688 deletions

View File

@@ -24,25 +24,19 @@ describe('Cloud Code', () => {
cloud: __dirname + '/cloud/cloudCodeRelativeFile.js',
}).then(() => {
Parse.Cloud.run('cloudCodeInFile', {}).then(result => {
expect(result).toEqual(
'It is possible to define cloud code in a file.'
);
expect(result).toEqual('It is possible to define cloud code in a file.');
done();
});
});
});
it('can load relative cloud code file', done => {
reconfigureServer({ cloud: './spec/cloud/cloudCodeAbsoluteFile.js' }).then(
() => {
Parse.Cloud.run('cloudCodeInFile', {}).then(result => {
expect(result).toEqual(
'It is possible to define cloud code in a file.'
);
done();
});
}
);
reconfigureServer({ cloud: './spec/cloud/cloudCodeAbsoluteFile.js' }).then(() => {
Parse.Cloud.run('cloudCodeInFile', {}).then(result => {
expect(result).toEqual('It is possible to define cloud code in a file.');
done();
});
});
});
it('can create functions', done => {
@@ -137,9 +131,7 @@ describe('Cloud Code', () => {
obj.set('foo', 'bar');
obj.save().then(
function () {
fail(
'Should not have been able to save BeforeSaveFailWithErrorCode class.'
);
fail('Should not have been able to save BeforeSaveFailWithErrorCode class.');
done();
},
function (error) {
@@ -851,18 +843,10 @@ describe('Cloud Code', () => {
expect(req.params.dateList[0].getTime()).toBe(1463907600000);
expect(req.params.complexStructure.date[0] instanceof Date).toBe(true);
expect(req.params.complexStructure.date[0].getTime()).toBe(1463907600000);
expect(req.params.complexStructure.deepDate.date[0] instanceof Date).toBe(
true
);
expect(req.params.complexStructure.deepDate.date[0].getTime()).toBe(
1463907600000
);
expect(
req.params.complexStructure.deepDate2[0].date instanceof Date
).toBe(true);
expect(req.params.complexStructure.deepDate2[0].date.getTime()).toBe(
1463907600000
);
expect(req.params.complexStructure.deepDate.date[0] instanceof Date).toBe(true);
expect(req.params.complexStructure.deepDate.date[0].getTime()).toBe(1463907600000);
expect(req.params.complexStructure.deepDate2[0].date instanceof Date).toBe(true);
expect(req.params.complexStructure.deepDate2[0].date.getTime()).toBe(1463907600000);
// Regression for #2294
expect(req.params.file instanceof Parse.File).toBe(true);
expect(req.params.file.url()).toEqual('https://some.url');
@@ -1291,9 +1275,7 @@ describe('Cloud Code', () => {
});
const TestObject = Parse.Object.extend('TestObject');
const BeforeSaveUnchangedObject = Parse.Object.extend(
'BeforeSaveUnchanged'
);
const BeforeSaveUnchangedObject = Parse.Object.extend('BeforeSaveUnchanged');
const BeforeSaveChangedObject = Parse.Object.extend('BeforeSaveChanged');
const aTestObject = new TestObject();
@@ -1303,27 +1285,19 @@ describe('Cloud Code', () => {
.then(aTestObject => {
const aBeforeSaveUnchangedObject = new BeforeSaveUnchangedObject();
aBeforeSaveUnchangedObject.set('aTestObject', aTestObject);
expect(
aBeforeSaveUnchangedObject.get('aTestObject').get('foo')
).toEqual('bar');
expect(aBeforeSaveUnchangedObject.get('aTestObject').get('foo')).toEqual('bar');
return aBeforeSaveUnchangedObject.save();
})
.then(aBeforeSaveUnchangedObject => {
expect(
aBeforeSaveUnchangedObject.get('aTestObject').get('foo')
).toEqual('bar');
expect(aBeforeSaveUnchangedObject.get('aTestObject').get('foo')).toEqual('bar');
const aBeforeSaveChangedObject = new BeforeSaveChangedObject();
aBeforeSaveChangedObject.set('aTestObject', aTestObject);
expect(aBeforeSaveChangedObject.get('aTestObject').get('foo')).toEqual(
'bar'
);
expect(aBeforeSaveChangedObject.get('aTestObject').get('foo')).toEqual('bar');
return aBeforeSaveChangedObject.save();
})
.then(aBeforeSaveChangedObject => {
expect(aBeforeSaveChangedObject.get('aTestObject').get('foo')).toEqual(
'bar'
);
expect(aBeforeSaveChangedObject.get('aTestObject').get('foo')).toEqual('bar');
expect(aBeforeSaveChangedObject.get('foo')).toEqual('baz');
done();
});
@@ -1479,13 +1453,13 @@ describe('Cloud Code', () => {
obj.set('points', 10);
obj.set('num', 10);
obj.save(null, { useMasterKey: true }).then(function () {
Parse.Cloud.run('cloudIncrementClassFunction', { objectId: obj.id }).then(
function (savedObj) {
expect(savedObj.get('num')).toEqual(1);
expect(savedObj.get('points')).toEqual(0);
done();
}
);
Parse.Cloud.run('cloudIncrementClassFunction', { objectId: obj.id }).then(function (
savedObj
) {
expect(savedObj.get('num')).toEqual(1);
expect(savedObj.get('points')).toEqual(0);
done();
});
});
});
@@ -2241,9 +2215,7 @@ describe('afterFind hooks', () => {
return req.query;
});
const obj0 = new Parse.Object('MyObject')
.set('white', true)
.set('black', true);
const obj0 = new Parse.Object('MyObject').set('white', true).set('black', true);
obj0.save().then(() => {
new Parse.Query('MyObject').first().then(result => {
expect(result.get('white')).toBe(true);
@@ -2254,9 +2226,7 @@ describe('afterFind hooks', () => {
});
it('should not alter select', done => {
const obj0 = new Parse.Object('MyObject')
.set('white', true)
.set('black', true);
const obj0 = new Parse.Object('MyObject').set('white', true).set('black', true);
obj0.save().then(() => {
new Parse.Query('MyObject').first().then(result => {
expect(result.get('white')).toBe(true);
@@ -2336,14 +2306,10 @@ describe('afterFind hooks', () => {
it('should validate triggers correctly', () => {
expect(() => {
Parse.Cloud.beforeSave('_Session', () => {});
}).toThrow(
'Only the afterLogout trigger is allowed for the _Session class.'
);
}).toThrow('Only the afterLogout trigger is allowed for the _Session class.');
expect(() => {
Parse.Cloud.afterSave('_Session', () => {});
}).toThrow(
'Only the afterLogout trigger is allowed for the _Session class.'
);
}).toThrow('Only the afterLogout trigger is allowed for the _Session class.');
expect(() => {
Parse.Cloud.beforeSave('_PushStatus', () => {});
}).toThrow('Only afterSave is allowed on _PushStatus');
@@ -2352,44 +2318,28 @@ describe('afterFind hooks', () => {
}).not.toThrow();
expect(() => {
Parse.Cloud.beforeLogin(() => {});
}).not.toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).not.toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.beforeLogin('_User', () => {});
}).not.toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).not.toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.beforeLogin(Parse.User, () => {});
}).not.toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).not.toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.beforeLogin('SomeClass', () => {});
}).toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.afterLogin(() => {});
}).not.toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).not.toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.afterLogin('_User', () => {});
}).not.toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).not.toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.afterLogin(Parse.User, () => {});
}).not.toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).not.toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.afterLogin('SomeClass', () => {});
}).toThrow(
'Only the _User class is allowed for the beforeLogin and afterLogin triggers'
);
}).toThrow('Only the _User class is allowed for the beforeLogin and afterLogin triggers');
expect(() => {
Parse.Cloud.afterLogout(() => {});
}).not.toThrow();
@@ -2398,14 +2348,10 @@ describe('afterFind hooks', () => {
}).not.toThrow();
expect(() => {
Parse.Cloud.afterLogout('_User', () => {});
}).toThrow(
'Only the _Session class is allowed for the afterLogout trigger.'
);
}).toThrow('Only the _Session class is allowed for the afterLogout trigger.');
expect(() => {
Parse.Cloud.afterLogout('SomeClass', () => {});
}).toThrow(
'Only the _Session class is allowed for the afterLogout trigger.'
);
}).toThrow('Only the _Session class is allowed for the afterLogout trigger.');
});
it('should skip afterFind hooks for aggregate', done => {
@@ -2723,17 +2669,14 @@ describe('beforeLogin hook', () => {
const createFileSpy = spyOn(mockAdapter, 'createFile').and.callThrough();
Parse.Cloud.beforeSaveFile(() => {
const newFile = new Parse.File('some-file.txt');
newFile._url =
'http://www.somewhere.com/parse/files/some-app-id/some-file.txt';
newFile._url = 'http://www.somewhere.com/parse/files/some-app-id/some-file.txt';
return newFile;
});
const file = new Parse.File('popeye.txt', [1, 2, 3], 'text/plain');
const result = await file.save({ useMasterKey: true });
expect(result).toBe(file);
expect(result._name).toBe('some-file.txt');
expect(result._url).toBe(
'http://www.somewhere.com/parse/files/some-app-id/some-file.txt'
);
expect(result._url).toBe('http://www.somewhere.com/parse/files/some-app-id/some-file.txt');
expect(createFileSpy).not.toHaveBeenCalled();
});
@@ -2785,11 +2728,7 @@ describe('beforeLogin hook', () => {
Parse.Cloud.beforeSaveFile(async req => {
expect(req.triggerName).toEqual('beforeSaveFile');
expect(req.fileSize).toBe(3);
const newFile = new Parse.File(
'donald_duck.pdf',
[4, 5, 6],
'application/pdf'
);
const newFile = new Parse.File('donald_duck.pdf', [4, 5, 6], 'application/pdf');
newFile.setMetadata({ foo: 'bar' });
newFile.setTags({ tagA: 'some-tag' });
return newFile;
@@ -2814,9 +2753,7 @@ describe('beforeLogin hook', () => {
newOptions
);
const expectedFileName = 'donald_duck.pdf';
expect(file._name.indexOf(expectedFileName)).toBe(
file._name.length - expectedFileName.length
);
expect(file._name.indexOf(expectedFileName)).toBe(file._name.length - expectedFileName.length);
});
it('beforeSaveFile should contain metadata and tags saved from client', async () => {
@@ -2868,8 +2805,7 @@ describe('beforeLogin hook', () => {
Parse.Cloud.beforeSaveFile(req => {
expect(req.fileSize).toBe(3);
const newFile = new Parse.File('some-file.txt');
newFile._url =
'http://www.somewhere.com/parse/files/some-app-id/some-file.txt';
newFile._url = 'http://www.somewhere.com/parse/files/some-app-id/some-file.txt';
return newFile;
});
Parse.Cloud.afterSaveFile(req => {
@@ -2879,9 +2815,7 @@ describe('beforeLogin hook', () => {
const result = await file.save({ useMasterKey: true });
expect(result).toBe(result);
expect(result._name).toBe('some-file.txt');
expect(result._url).toBe(
'http://www.somewhere.com/parse/files/some-app-id/some-file.txt'
);
expect(result._url).toBe('http://www.somewhere.com/parse/files/some-app-id/some-file.txt');
expect(createFileSpy).not.toHaveBeenCalled();
});
@@ -2920,11 +2854,7 @@ describe('beforeLogin hook', () => {
Parse.Cloud.beforeSaveFile(async req => {
expect(req.fileSize).toBe(3);
expect(req.master).toBe(true);
const newFile = new Parse.File(
'donald_duck.pdf',
[4, 5, 6, 7, 8, 9],
'application/pdf'
);
const newFile = new Parse.File('donald_duck.pdf', [4, 5, 6, 7, 8, 9], 'application/pdf');
return newFile;
});
Parse.Cloud.afterSaveFile(async req => {