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

@@ -37,10 +37,7 @@ describe('ParseGraphQLController', () => {
const defaultFind = databaseController.find.bind(databaseController);
databaseController.find = async (className, query, ...args) => {
if (
className === GraphQLConfigClassName &&
isEqual(query, { objectId: GraphQLConfigId })
) {
if (className === GraphQLConfigClassName && isEqual(query, { objectId: GraphQLConfigId })) {
const graphQLConfigRecord = getConfigFromDb();
return graphQLConfigRecord ? [graphQLConfigRecord] : [];
} else {
@@ -49,12 +46,7 @@ describe('ParseGraphQLController', () => {
};
const defaultUpdate = databaseController.update.bind(databaseController);
databaseController.update = async (
className,
query,
update,
fullQueryOptions
) => {
databaseController.update = async (className, query, update, fullQueryOptions) => {
databaseUpdateArgs = [className, query, update, fullQueryOptions];
if (
className === GraphQLConfigClassName &&
@@ -89,9 +81,7 @@ describe('ParseGraphQLController', () => {
cacheController,
mountGraphQL: false,
})
).toThrow(
'ParseGraphQLController requires a "databaseController" to be instantiated.'
);
).toThrow('ParseGraphQLController requires a "databaseController" to be instantiated.');
});
it('should construct without a cacheController', () => {
expect(
@@ -197,13 +187,13 @@ describe('ParseGraphQLController', () => {
describe('updateGraphQLConfig', () => {
const successfulUpdateResponse = { response: { result: true } };
it('should throw if graphQLConfig is not provided', async function() {
it('should throw if graphQLConfig is not provided', async function () {
const parseGraphQLController = new ParseGraphQLController({
databaseController,
});
expectAsync(
parseGraphQLController.updateGraphQLConfig()
).toBeRejectedWith('You must provide a graphQLConfig!');
expectAsync(parseGraphQLController.updateGraphQLConfig()).toBeRejectedWith(
'You must provide a graphQLConfig!'
);
});
it('should correct update the graphQLConfig object using the databaseController', async () => {
@@ -235,32 +225,22 @@ describe('ParseGraphQLController', () => {
const parseGraphQLController = new ParseGraphQLController({
databaseController,
});
expectAsync(
parseGraphQLController.updateGraphQLConfig([])
).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig(function() {})
).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig(Promise.resolve({}))
).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig('')
).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig({})
).toBeResolvedTo(successfulUpdateResponse);
expectAsync(parseGraphQLController.updateGraphQLConfig([])).toBeRejected();
expectAsync(parseGraphQLController.updateGraphQLConfig(function () {})).toBeRejected();
expectAsync(parseGraphQLController.updateGraphQLConfig(Promise.resolve({}))).toBeRejected();
expectAsync(parseGraphQLController.updateGraphQLConfig('')).toBeRejected();
expectAsync(parseGraphQLController.updateGraphQLConfig({})).toBeResolvedTo(
successfulUpdateResponse
);
});
it('should throw if graphQLConfig has an invalid root key', async () => {
const parseGraphQLController = new ParseGraphQLController({
databaseController,
});
expectAsync(
parseGraphQLController.updateGraphQLConfig({ invalidKey: true })
).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig({})
).toBeResolvedTo(successfulUpdateResponse);
expectAsync(parseGraphQLController.updateGraphQLConfig({ invalidKey: true })).toBeRejected();
expectAsync(parseGraphQLController.updateGraphQLConfig({})).toBeResolvedTo(
successfulUpdateResponse
);
});
it('should throw if graphQLConfig has invalid class filters', async () => {
const parseGraphQLController = new ParseGraphQLController({
@@ -298,9 +278,7 @@ describe('ParseGraphQLController', () => {
const parseGraphQLController = new ParseGraphQLController({
databaseController,
});
expectAsync(
parseGraphQLController.updateGraphQLConfig({ classConfigs: {} })
).toBeRejected();
expectAsync(parseGraphQLController.updateGraphQLConfig({ classConfigs: {} })).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig({ classConfigs: [null] })
).toBeRejected();
@@ -314,9 +292,9 @@ describe('ParseGraphQLController', () => {
classConfigs: [{ className: 'ValidClass' }, null],
})
).toBeRejected();
expectAsync(
parseGraphQLController.updateGraphQLConfig({ classConfigs: [] })
).toBeResolvedTo(successfulUpdateResponse);
expectAsync(parseGraphQLController.updateGraphQLConfig({ classConfigs: [] })).toBeResolvedTo(
successfulUpdateResponse
);
expectAsync(
parseGraphQLController.updateGraphQLConfig({
classConfigs: [
@@ -939,34 +917,26 @@ describe('ParseGraphQLController', () => {
let cacheBeforeValue;
let cacheAfterValue;
cacheBeforeValue = await cacheController.graphQL.get(
mountedController.configCacheKey
);
cacheBeforeValue = await cacheController.graphQL.get(mountedController.configCacheKey);
expect(cacheBeforeValue).toBeNull();
await mountedController.updateGraphQLConfig({
enabledForClasses: ['SuperCar'],
});
cacheAfterValue = await cacheController.graphQL.get(
mountedController.configCacheKey
);
cacheAfterValue = await cacheController.graphQL.get(mountedController.configCacheKey);
expect(cacheAfterValue).toEqual({ enabledForClasses: ['SuperCar'] });
// reset
removeConfigFromDb();
cacheController.graphQL.clear();
cacheBeforeValue = await cacheController.graphQL.get(
unmountedController.configCacheKey
);
cacheBeforeValue = await cacheController.graphQL.get(unmountedController.configCacheKey);
expect(cacheBeforeValue).toBeNull();
await unmountedController.updateGraphQLConfig({
enabledForClasses: ['SuperCar'],
});
cacheAfterValue = await cacheController.graphQL.get(
unmountedController.configCacheKey
);
cacheAfterValue = await cacheController.graphQL.get(unmountedController.configCacheKey);
expect(cacheAfterValue).toBeNull();
});
});