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

@@ -1,11 +1,9 @@
const LoggerController = require('../lib/Controllers/LoggerController')
.LoggerController;
const LoggerController = require('../lib/Controllers/LoggerController').LoggerController;
const WinstonLoggerAdapter = require('../lib/Adapters/Logger/WinstonLoggerAdapter')
.WinstonLoggerAdapter;
const GridFSBucketAdapter = require('../lib/Adapters/Files/GridFSBucketAdapter')
.GridFSBucketAdapter;
const GridStoreAdapter = require('../lib/Adapters/Files/GridStoreAdapter')
.GridStoreAdapter;
const GridStoreAdapter = require('../lib/Adapters/Files/GridStoreAdapter').GridStoreAdapter;
const Config = require('../lib/Config');
const FilesController = require('../lib/Controllers/FilesController').default;
const databaseURI = 'mongodb://localhost:27017/parse';
@@ -26,9 +24,7 @@ const mockAdapter = {
describe('FilesController', () => {
it('should properly expand objects', done => {
const config = Config.get(Parse.applicationId);
const gridStoreAdapter = new GridFSBucketAdapter(
'mongodb://localhost:27017/parse'
);
const gridStoreAdapter = new GridFSBucketAdapter('mongodb://localhost:27017/parse');
const filesController = new FilesController(gridStoreAdapter);
const result = filesController.expandFilesInObject(config, function () {});
@@ -58,16 +54,12 @@ describe('FilesController', () => {
() => setImmediate(() => Promise.resolve('done'))
)
.then(() => new Promise(resolve => setTimeout(resolve, 200)))
.then(() =>
logController.getLogs({ from: Date.now() - 1000, size: 1000 })
)
.then(() => logController.getLogs({ from: Date.now() - 1000, size: 1000 }))
.then(logs => {
// we get two logs here: 1. the source of the failure to save the file
// and 2 the message that will be sent back to the client.
const log1 = logs.find(
x => x.message === 'Error creating a file: it failed with xyz'
);
const log1 = logs.find(x => x.message === 'Error creating a file: it failed with xyz');
expect(log1.level).toBe('error');
const log2 = logs.find(x => x.message === 'it failed with xyz');
@@ -93,9 +85,7 @@ describe('FilesController', () => {
it('should add a unique hash to the file name when the preserveFileName option is false', done => {
const config = Config.get(Parse.applicationId);
const gridStoreAdapter = new GridFSBucketAdapter(
'mongodb://localhost:27017/parse'
);
const gridStoreAdapter = new GridFSBucketAdapter('mongodb://localhost:27017/parse');
spyOn(gridStoreAdapter, 'createFile');
gridStoreAdapter.createFile.and.returnValue(Promise.resolve());
const fileName = 'randomFileName.pdf';
@@ -116,9 +106,7 @@ describe('FilesController', () => {
it('should not add a unique hash to the file name when the preserveFileName option is true', done => {
const config = Config.get(Parse.applicationId);
const gridStoreAdapter = new GridFSBucketAdapter(
'mongodb://localhost:27017/parse'
);
const gridStoreAdapter = new GridFSBucketAdapter('mongodb://localhost:27017/parse');
spyOn(gridStoreAdapter, 'createFile');
gridStoreAdapter.createFile.and.returnValue(Promise.resolve());
const fileName = 'randomFileName.pdf';
@@ -129,9 +117,7 @@ describe('FilesController', () => {
filesController.createFile(config, fileName);
expect(gridStoreAdapter.createFile).toHaveBeenCalledTimes(1);
expect(gridStoreAdapter.createFile.calls.mostRecent().args[0]).toEqual(
fileName
);
expect(gridStoreAdapter.createFile.calls.mostRecent().args[0]).toEqual(fileName);
done();
});
@@ -146,18 +132,14 @@ describe('FilesController', () => {
});
it('should reject slashes in file names', done => {
const gridStoreAdapter = new GridFSBucketAdapter(
'mongodb://localhost:27017/parse'
);
const gridStoreAdapter = new GridFSBucketAdapter('mongodb://localhost:27017/parse');
const fileName = 'foo/randomFileName.pdf';
expect(gridStoreAdapter.validateFilename(fileName)).not.toBe(null);
done();
});
it('should also reject slashes in file names', done => {
const gridStoreAdapter = new GridStoreAdapter(
'mongodb://localhost:27017/parse'
);
const gridStoreAdapter = new GridStoreAdapter('mongodb://localhost:27017/parse');
const fileName = 'foo/randomFileName.pdf';
expect(gridStoreAdapter.validateFilename(fileName)).not.toBe(null);
done();