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:
@@ -1,16 +1,10 @@
|
||||
const Config = require('../lib/Config');
|
||||
const Parse = require('parse/node');
|
||||
const request = require('../lib/request');
|
||||
const {
|
||||
className,
|
||||
createRole,
|
||||
createUser,
|
||||
logIn,
|
||||
updateCLP,
|
||||
} = require('./dev');
|
||||
const { className, createRole, createUser, logIn, updateCLP } = require('./dev');
|
||||
|
||||
describe('ProtectedFields', function() {
|
||||
it('should handle and empty protectedFields', async function() {
|
||||
describe('ProtectedFields', function () {
|
||||
it('should handle and empty protectedFields', async function () {
|
||||
const protectedFields = {};
|
||||
await reconfigureServer({ protectedFields });
|
||||
|
||||
@@ -26,8 +20,8 @@ describe('ProtectedFields', function() {
|
||||
expect(fetched.has('favoriteColor')).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('interaction with legacy userSensitiveFields', function() {
|
||||
it('should fall back on sensitive fields if protected fields are not configured', async function() {
|
||||
describe('interaction with legacy userSensitiveFields', function () {
|
||||
it('should fall back on sensitive fields if protected fields are not configured', async function () {
|
||||
const userSensitiveFields = ['phoneNumber', 'timeZone'];
|
||||
|
||||
const protectedFields = { _User: { '*': ['email'] } };
|
||||
@@ -49,7 +43,7 @@ describe('ProtectedFields', function() {
|
||||
expect(fetched.has('favoriteColor')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should merge protected and sensitive for extra safety', async function() {
|
||||
it('should merge protected and sensitive for extra safety', async function () {
|
||||
const userSensitiveFields = ['phoneNumber', 'timeZone'];
|
||||
|
||||
const protectedFields = { _User: { '*': ['email', 'favoriteFood'] } };
|
||||
@@ -73,23 +67,17 @@ describe('ProtectedFields', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('non user class', function() {
|
||||
it('should hide fields in a non user class', async function() {
|
||||
describe('non user class', function () {
|
||||
it('should hide fields in a non user class', async function () {
|
||||
const protectedFields = {
|
||||
ClassA: { '*': ['foo'] },
|
||||
ClassB: { '*': ['bar'] },
|
||||
};
|
||||
await reconfigureServer({ protectedFields });
|
||||
|
||||
const objA = await new Parse.Object('ClassA')
|
||||
.set('foo', 'zzz')
|
||||
.set('bar', 'yyy')
|
||||
.save();
|
||||
const objA = await new Parse.Object('ClassA').set('foo', 'zzz').set('bar', 'yyy').save();
|
||||
|
||||
const objB = await new Parse.Object('ClassB')
|
||||
.set('foo', 'zzz')
|
||||
.set('bar', 'yyy')
|
||||
.save();
|
||||
const objB = await new Parse.Object('ClassB').set('foo', 'zzz').set('bar', 'yyy').save();
|
||||
|
||||
const [fetchedA, fetchedB] = await Promise.all([
|
||||
new Parse.Query('ClassA').get(objA.id),
|
||||
@@ -103,7 +91,7 @@ describe('ProtectedFields', function() {
|
||||
expect(fetchedB.has('bar')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should hide fields in non user class and non standard user field at same time', async function() {
|
||||
it('should hide fields in non user class and non standard user field at same time', async function () {
|
||||
const protectedFields = {
|
||||
_User: { '*': ['phoneNumber'] },
|
||||
ClassA: { '*': ['foo'] },
|
||||
@@ -122,15 +110,9 @@ describe('ProtectedFields', function() {
|
||||
user.set('favoriteFood', 'pizza');
|
||||
await user.save();
|
||||
|
||||
const objA = await new Parse.Object('ClassA')
|
||||
.set('foo', 'zzz')
|
||||
.set('bar', 'yyy')
|
||||
.save();
|
||||
const objA = await new Parse.Object('ClassA').set('foo', 'zzz').set('bar', 'yyy').save();
|
||||
|
||||
const objB = await new Parse.Object('ClassB')
|
||||
.set('foo', 'zzz')
|
||||
.set('bar', 'yyy')
|
||||
.save();
|
||||
const objB = await new Parse.Object('ClassB').set('foo', 'zzz').set('bar', 'yyy').save();
|
||||
|
||||
const [fetchedUser, fetchedA, fetchedB] = await Promise.all([
|
||||
new Parse.Query(Parse.User).get(user.id),
|
||||
@@ -823,10 +805,7 @@ describe('ProtectedFields', function() {
|
||||
},
|
||||
})
|
||||
).toBeRejectedWith(
|
||||
new Parse.Error(
|
||||
Parse.Error.INVALID_JSON,
|
||||
`Default field '${field}' can not be protected`
|
||||
)
|
||||
new Parse.Error(Parse.Error.INVALID_JSON, `Default field '${field}' can not be protected`)
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -949,10 +928,7 @@ describe('ProtectedFields', function() {
|
||||
|
||||
await Parse.User.logOut();
|
||||
|
||||
[user1, user2] = await Promise.all([
|
||||
createUser('user1'),
|
||||
createUser('user2'),
|
||||
]);
|
||||
[user1, user2] = await Promise.all([createUser('user1'), createUser('user2')]);
|
||||
|
||||
obj1 = new Parse.Object(className);
|
||||
obj2 = new Parse.Object(className);
|
||||
@@ -1151,10 +1127,7 @@ describe('ProtectedFields', function() {
|
||||
async function initialize() {
|
||||
await Config.get(Parse.applicationId).database.schemaCache.clear();
|
||||
|
||||
[user1, user2] = await Promise.all([
|
||||
createUser('user1'),
|
||||
createUser('user2'),
|
||||
]);
|
||||
[user1, user2] = await Promise.all([createUser('user1'), createUser('user2')]);
|
||||
|
||||
obj1 = new Parse.Object(className);
|
||||
obj2 = new Parse.Object(className);
|
||||
@@ -1244,10 +1217,7 @@ describe('ProtectedFields', function() {
|
||||
|
||||
const object = await obj1.fetch();
|
||||
|
||||
expect(object.get('test')).toBe(
|
||||
undefined,
|
||||
'Field should not be visible - protected by role'
|
||||
);
|
||||
expect(object.get('test')).toBe(undefined, 'Field should not be visible - protected by role');
|
||||
expect(object.get('owner')).toBe(
|
||||
undefined,
|
||||
'Field should not be visible - protected by role'
|
||||
@@ -1452,9 +1422,7 @@ describe('ProtectedFields', function() {
|
||||
expect(object.get('test')).toBeDefined(
|
||||
"Being both auhenticated and having a role leads to clearing protection on 'test' (by role rules)"
|
||||
);
|
||||
expect(object.get('owner')).toBeDefined(
|
||||
'All authenticated users allowed to see "owner"'
|
||||
);
|
||||
expect(object.get('owner')).toBeDefined('All authenticated users allowed to see "owner"');
|
||||
expect(object.get('testers')).toBeDefined();
|
||||
|
||||
done();
|
||||
@@ -1588,10 +1556,7 @@ describe('ProtectedFields', function() {
|
||||
undefined,
|
||||
'Should NOT be in response - protected by "userField:owner"'
|
||||
);
|
||||
expect(object.owner).toBe(
|
||||
undefined,
|
||||
'Should not be in response - not included in "keys"'
|
||||
);
|
||||
expect(object.owner).toBe(undefined, 'Should not be in response - not included in "keys"');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -1634,10 +1599,7 @@ describe('ProtectedFields', function() {
|
||||
undefined,
|
||||
'Should not be in response - protected by "userField:owner"'
|
||||
);
|
||||
expect(object.owner).toBe(
|
||||
undefined,
|
||||
'Should not be in response - not included in "keys"'
|
||||
);
|
||||
expect(object.owner).toBe(undefined, 'Should not be in response - not included in "keys"');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -1667,10 +1629,7 @@ describe('ProtectedFields', function() {
|
||||
undefined,
|
||||
'Should not be in response - protected by "userField:owner"'
|
||||
);
|
||||
expect(object['owner']).toBe(
|
||||
undefined,
|
||||
'Should not be in response - not included in "keys"'
|
||||
);
|
||||
expect(object['owner']).toBe(undefined, 'Should not be in response - not included in "keys"');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -1703,10 +1662,7 @@ describe('ProtectedFields', function() {
|
||||
undefined,
|
||||
'Should not be in response - protected by "userField:owner"'
|
||||
);
|
||||
expect(object.owner).toBe(
|
||||
undefined,
|
||||
'Should not be in response - not included in "keys"'
|
||||
);
|
||||
expect(object.owner).toBe(undefined, 'Should not be in response - not included in "keys"');
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user