refactor: Add a few lint rules to test files in /spec (#9815)
This commit is contained in:
@@ -12,28 +12,28 @@ describe('GameCenterAuth Adapter', function () {
|
|||||||
const gcProd4 = fs.readFileSync(path.resolve(__dirname, '../../support/cert/gc-prod-4.cer'));
|
const gcProd4 = fs.readFileSync(path.resolve(__dirname, '../../support/cert/gc-prod-4.cer'));
|
||||||
const digicertPem = fs.readFileSync(path.resolve(__dirname, '../../support/cert/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem')).toString();
|
const digicertPem = fs.readFileSync(path.resolve(__dirname, '../../support/cert/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem')).toString();
|
||||||
|
|
||||||
mockFetch([
|
mockFetch([
|
||||||
{
|
{
|
||||||
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
|
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
response: {
|
response: {
|
||||||
ok: true,
|
ok: true,
|
||||||
headers: new Map(),
|
headers: new Map(),
|
||||||
arrayBuffer: () => Promise.resolve(
|
arrayBuffer: () => Promise.resolve(
|
||||||
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
|
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
|
||||||
),
|
),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
|
||||||
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
|
method: 'GET',
|
||||||
method: 'GET',
|
response: {
|
||||||
response: {
|
ok: true,
|
||||||
ok: true,
|
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
|
||||||
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
|
text: () => Promise.resolve(digicertPem),
|
||||||
text: () => Promise.resolve(digicertPem),
|
},
|
||||||
},
|
}
|
||||||
}
|
]);
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Test config failing due to missing params or wrong types', function () {
|
describe('Test config failing due to missing params or wrong types', function () {
|
||||||
|
|||||||
@@ -3502,9 +3502,9 @@ describe('afterLogin hook', () => {
|
|||||||
'X-Parse-REST-API-Key': 'rest',
|
'X-Parse-REST-API-Key': 'rest',
|
||||||
'X-Parse-Cloud-Context': '{"a":"a"}',
|
'X-Parse-Cloud-Context': '{"a":"a"}',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({_context: { hello: 'world' }}),
|
body: JSON.stringify({ _context: { hello: 'world' } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have access to context when saving a new object', async () => {
|
it('should have access to context when saving a new object', async () => {
|
||||||
@@ -3929,7 +3929,7 @@ describe('saveFile hooks', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Parse.File hooks', () => {
|
describe('Parse.File hooks', () => {
|
||||||
it('find hooks should run', async () => {
|
it('find hooks should run', async () => {
|
||||||
const file = new Parse.File('popeye.txt', [1, 2, 3], 'text/plain');
|
const file = new Parse.File('popeye.txt', [1, 2, 3], 'text/plain');
|
||||||
await file.save({ useMasterKey: true });
|
await file.save({ useMasterKey: true });
|
||||||
@@ -4047,7 +4047,7 @@ describe('Parse.File hooks', () => {
|
|||||||
});
|
});
|
||||||
expect(response.headers['content-disposition']).toBe(`attachment;filename=${file._name}`);
|
expect(response.headers['content-disposition']).toBe(`attachment;filename=${file._name}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Cloud Config hooks', () => {
|
describe('Cloud Config hooks', () => {
|
||||||
function testConfig() {
|
function testConfig() {
|
||||||
|
|||||||
@@ -647,7 +647,6 @@ describe('Email Verification Token Expiration:', () => {
|
|||||||
|
|
||||||
it_id('b6c87f35-d887-477d-bc86-a9217a424f53')(it)('setting the email on the user should set a new email verification token and new expiration date for the token when expire email verify token flag is set', async () => {
|
it_id('b6c87f35-d887-477d-bc86-a9217a424f53')(it)('setting the email on the user should set a new email verification token and new expiration date for the token when expire email verify token flag is set', async () => {
|
||||||
const user = new Parse.User();
|
const user = new Parse.User();
|
||||||
let userBeforeEmailReset;
|
|
||||||
|
|
||||||
let sendEmailOptions;
|
let sendEmailOptions;
|
||||||
const sendPromise = resolvingPromise();
|
const sendPromise = resolvingPromise();
|
||||||
@@ -680,7 +679,7 @@ describe('Email Verification Token Expiration:', () => {
|
|||||||
return results[0];
|
return results[0];
|
||||||
});
|
});
|
||||||
expect(typeof userFromDb).toBe('object');
|
expect(typeof userFromDb).toBe('object');
|
||||||
userBeforeEmailReset = userFromDb;
|
const userBeforeEmailReset = userFromDb;
|
||||||
|
|
||||||
// trigger another token generation by setting the email
|
// trigger another token generation by setting the email
|
||||||
user.set('email', 'user@parse.com');
|
user.set('email', 'user@parse.com');
|
||||||
@@ -713,7 +712,6 @@ describe('Email Verification Token Expiration:', () => {
|
|||||||
const user = new Parse.User();
|
const user = new Parse.User();
|
||||||
let sendEmailOptions;
|
let sendEmailOptions;
|
||||||
let sendVerificationEmailCallCount = 0;
|
let sendVerificationEmailCallCount = 0;
|
||||||
let userBeforeRequest;
|
|
||||||
const promise1 = resolvingPromise();
|
const promise1 = resolvingPromise();
|
||||||
const promise2 = resolvingPromise();
|
const promise2 = resolvingPromise();
|
||||||
const emailAdapter = {
|
const emailAdapter = {
|
||||||
@@ -748,7 +746,7 @@ describe('Email Verification Token Expiration:', () => {
|
|||||||
return results[0];
|
return results[0];
|
||||||
});
|
});
|
||||||
// store this user before we make our email request
|
// store this user before we make our email request
|
||||||
userBeforeRequest = newUser;
|
const userBeforeRequest = newUser;
|
||||||
|
|
||||||
expect(sendVerificationEmailCallCount).toBe(1);
|
expect(sendVerificationEmailCallCount).toBe(1);
|
||||||
|
|
||||||
@@ -1011,7 +1009,7 @@ describe('Email Verification Token Expiration:', () => {
|
|||||||
})
|
})
|
||||||
.then(fail)
|
.then(fail)
|
||||||
.catch(response => response);
|
.catch(response => response);
|
||||||
|
|
||||||
expect(response.status).toBe(400);
|
expect(response.status).toBe(400);
|
||||||
expect(sendVerificationEmailCallCount).toBe(0);
|
expect(sendVerificationEmailCallCount).toBe(0);
|
||||||
expect(sendEmailOptions).not.toBeDefined();
|
expect(sendEmailOptions).not.toBeDefined();
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ describe('ParseGraphQLServer', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await createGQLFromParseServer(parseServer);
|
await createGQLFromParseServer(parseServer);
|
||||||
|
|
||||||
const subscriptionClient = new SubscriptionClient(
|
const subscriptionClient = new SubscriptionClient(
|
||||||
'ws://localhost:13377/subscriptions',
|
'ws://localhost:13377/subscriptions',
|
||||||
|
|||||||
@@ -1182,7 +1182,7 @@ describe('ParseLiveQuery', function () {
|
|||||||
await sleep(100);
|
await sleep(100);
|
||||||
expect(server.liveQueryServer.server.address()).toBeNull();
|
expect(server.liveQueryServer.server.address()).toBeNull();
|
||||||
expect(server.liveQueryServer.subscriber.isOpen).toBeFalse();
|
expect(server.liveQueryServer.subscriber.isOpen).toBeFalse();
|
||||||
|
|
||||||
liveQueryConnectionCount = await getConnectionsCount(server.liveQueryServer.server);
|
liveQueryConnectionCount = await getConnectionsCount(server.liveQueryServer.server);
|
||||||
expect(liveQueryConnectionCount).toBe(0);
|
expect(liveQueryConnectionCount).toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5312,7 +5312,7 @@ describe('Parse.Query testing', () => {
|
|||||||
const child = new Parse.Object('Child');
|
const child = new Parse.Object('Child');
|
||||||
child.set('key', 'value');
|
child.set('key', 'value');
|
||||||
await child.save();
|
await child.save();
|
||||||
|
|
||||||
const parent = new Parse.Object('Parent');
|
const parent = new Parse.Object('Parent');
|
||||||
parent.set('some', {
|
parent.set('some', {
|
||||||
nested: {
|
nested: {
|
||||||
@@ -5322,19 +5322,19 @@ describe('Parse.Query testing', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
await parent.save();
|
await parent.save();
|
||||||
|
|
||||||
const query1 = await new Parse.Query('Parent')
|
const query1 = await new Parse.Query('Parent')
|
||||||
.equalTo('some.nested.key.child', child)
|
.equalTo('some.nested.key.child', child)
|
||||||
.find();
|
.find();
|
||||||
|
|
||||||
expect(query1.length).toEqual(1);
|
expect(query1.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('queries nested key using containedIn', async () => {
|
it('queries nested key using containedIn', async () => {
|
||||||
const child = new Parse.Object('Child');
|
const child = new Parse.Object('Child');
|
||||||
child.set('key', 'value');
|
child.set('key', 'value');
|
||||||
await child.save();
|
await child.save();
|
||||||
|
|
||||||
const parent = new Parse.Object('Parent');
|
const parent = new Parse.Object('Parent');
|
||||||
parent.set('some', {
|
parent.set('some', {
|
||||||
nested: {
|
nested: {
|
||||||
@@ -5344,19 +5344,19 @@ describe('Parse.Query testing', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
await parent.save();
|
await parent.save();
|
||||||
|
|
||||||
const query1 = await new Parse.Query('Parent')
|
const query1 = await new Parse.Query('Parent')
|
||||||
.containedIn('some.nested.key.child', [child])
|
.containedIn('some.nested.key.child', [child])
|
||||||
.find();
|
.find();
|
||||||
|
|
||||||
expect(query1.length).toEqual(1);
|
expect(query1.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('queries nested key using matchesQuery', async () => {
|
it('queries nested key using matchesQuery', async () => {
|
||||||
const child = new Parse.Object('Child');
|
const child = new Parse.Object('Child');
|
||||||
child.set('key', 'value');
|
child.set('key', 'value');
|
||||||
await child.save();
|
await child.save();
|
||||||
|
|
||||||
const parent = new Parse.Object('Parent');
|
const parent = new Parse.Object('Parent');
|
||||||
parent.set('some', {
|
parent.set('some', {
|
||||||
nested: {
|
nested: {
|
||||||
@@ -5366,11 +5366,11 @@ describe('Parse.Query testing', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
await parent.save();
|
await parent.save();
|
||||||
|
|
||||||
const query1 = await new Parse.Query('Parent')
|
const query1 = await new Parse.Query('Parent')
|
||||||
.matchesQuery('some.nested.key.child', new Parse.Query('Child').equalTo('key', 'value'))
|
.matchesQuery('some.nested.key.child', new Parse.Query('Child').equalTo('key', 'value'))
|
||||||
.find();
|
.find();
|
||||||
|
|
||||||
expect(query1.length).toEqual(1);
|
expect(query1.length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe('Utils', () => {
|
|||||||
]
|
]
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
expect(Utils.encodeForUrl(value.input)).toBe(value.output);
|
expect(Utils.encodeForUrl(value.input)).toBe(value.output);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,20 @@ module.exports = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"no-console": "off",
|
indent: ["error", 2, { SwitchCase: 1 }],
|
||||||
"no-var": "error",
|
"linebreak-style": ["error", "unix"],
|
||||||
"no-unused-vars": "off",
|
"no-trailing-spaces": "error",
|
||||||
|
"eol-last": "error",
|
||||||
|
"space-in-parens": ["error", "never"],
|
||||||
|
"no-multiple-empty-lines": "warn",
|
||||||
|
"prefer-const": "error",
|
||||||
|
"space-infix-ops": "error",
|
||||||
"no-useless-escape": "off",
|
"no-useless-escape": "off",
|
||||||
}
|
"require-atomic-updates": "off",
|
||||||
|
"object-curly-spacing": ["error", "always"],
|
||||||
|
curly: ["error", "all"],
|
||||||
|
"block-spacing": ["error", "always"],
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -114,4 +114,4 @@ global.retryFlakyTests = function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CurrentSpecReporter;
|
module.exports = CurrentSpecReporter;
|
||||||
|
|||||||
Reference in New Issue
Block a user