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 digicertPem = fs.readFileSync(path.resolve(__dirname, '../../support/cert/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem')).toString();
|
||||
|
||||
mockFetch([
|
||||
{
|
||||
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
|
||||
method: 'GET',
|
||||
response: {
|
||||
ok: true,
|
||||
headers: new Map(),
|
||||
arrayBuffer: () => Promise.resolve(
|
||||
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
|
||||
),
|
||||
mockFetch([
|
||||
{
|
||||
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
|
||||
method: 'GET',
|
||||
response: {
|
||||
ok: true,
|
||||
headers: new Map(),
|
||||
arrayBuffer: () => Promise.resolve(
|
||||
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
|
||||
method: 'GET',
|
||||
response: {
|
||||
ok: true,
|
||||
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
|
||||
text: () => Promise.resolve(digicertPem),
|
||||
},
|
||||
}
|
||||
]);
|
||||
{
|
||||
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
|
||||
method: 'GET',
|
||||
response: {
|
||||
ok: true,
|
||||
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
|
||||
text: () => Promise.resolve(digicertPem),
|
||||
},
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
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-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 () => {
|
||||
@@ -3929,7 +3929,7 @@ describe('saveFile hooks', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parse.File hooks', () => {
|
||||
describe('Parse.File hooks', () => {
|
||||
it('find hooks should run', async () => {
|
||||
const file = new Parse.File('popeye.txt', [1, 2, 3], 'text/plain');
|
||||
await file.save({ useMasterKey: true });
|
||||
@@ -4047,7 +4047,7 @@ describe('Parse.File hooks', () => {
|
||||
});
|
||||
expect(response.headers['content-disposition']).toBe(`attachment;filename=${file._name}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Cloud Config hooks', () => {
|
||||
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 () => {
|
||||
const user = new Parse.User();
|
||||
let userBeforeEmailReset;
|
||||
|
||||
let sendEmailOptions;
|
||||
const sendPromise = resolvingPromise();
|
||||
@@ -680,7 +679,7 @@ describe('Email Verification Token Expiration:', () => {
|
||||
return results[0];
|
||||
});
|
||||
expect(typeof userFromDb).toBe('object');
|
||||
userBeforeEmailReset = userFromDb;
|
||||
const userBeforeEmailReset = userFromDb;
|
||||
|
||||
// trigger another token generation by setting the email
|
||||
user.set('email', 'user@parse.com');
|
||||
@@ -713,7 +712,6 @@ describe('Email Verification Token Expiration:', () => {
|
||||
const user = new Parse.User();
|
||||
let sendEmailOptions;
|
||||
let sendVerificationEmailCallCount = 0;
|
||||
let userBeforeRequest;
|
||||
const promise1 = resolvingPromise();
|
||||
const promise2 = resolvingPromise();
|
||||
const emailAdapter = {
|
||||
@@ -748,7 +746,7 @@ describe('Email Verification Token Expiration:', () => {
|
||||
return results[0];
|
||||
});
|
||||
// store this user before we make our email request
|
||||
userBeforeRequest = newUser;
|
||||
const userBeforeRequest = newUser;
|
||||
|
||||
expect(sendVerificationEmailCallCount).toBe(1);
|
||||
|
||||
@@ -1011,7 +1009,7 @@ describe('Email Verification Token Expiration:', () => {
|
||||
})
|
||||
.then(fail)
|
||||
.catch(response => response);
|
||||
|
||||
|
||||
expect(response.status).toBe(400);
|
||||
expect(sendVerificationEmailCallCount).toBe(0);
|
||||
expect(sendEmailOptions).not.toBeDefined();
|
||||
|
||||
@@ -456,7 +456,7 @@ describe('ParseGraphQLServer', () => {
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
await createGQLFromParseServer(parseServer);
|
||||
await createGQLFromParseServer(parseServer);
|
||||
|
||||
const subscriptionClient = new SubscriptionClient(
|
||||
'ws://localhost:13377/subscriptions',
|
||||
|
||||
@@ -1182,7 +1182,7 @@ describe('ParseLiveQuery', function () {
|
||||
await sleep(100);
|
||||
expect(server.liveQueryServer.server.address()).toBeNull();
|
||||
expect(server.liveQueryServer.subscriber.isOpen).toBeFalse();
|
||||
|
||||
|
||||
liveQueryConnectionCount = await getConnectionsCount(server.liveQueryServer.server);
|
||||
expect(liveQueryConnectionCount).toBe(0);
|
||||
});
|
||||
|
||||
@@ -5312,7 +5312,7 @@ describe('Parse.Query testing', () => {
|
||||
const child = new Parse.Object('Child');
|
||||
child.set('key', 'value');
|
||||
await child.save();
|
||||
|
||||
|
||||
const parent = new Parse.Object('Parent');
|
||||
parent.set('some', {
|
||||
nested: {
|
||||
@@ -5322,19 +5322,19 @@ describe('Parse.Query testing', () => {
|
||||
},
|
||||
});
|
||||
await parent.save();
|
||||
|
||||
|
||||
const query1 = await new Parse.Query('Parent')
|
||||
.equalTo('some.nested.key.child', child)
|
||||
.find();
|
||||
|
||||
|
||||
expect(query1.length).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
it('queries nested key using containedIn', async () => {
|
||||
const child = new Parse.Object('Child');
|
||||
child.set('key', 'value');
|
||||
await child.save();
|
||||
|
||||
|
||||
const parent = new Parse.Object('Parent');
|
||||
parent.set('some', {
|
||||
nested: {
|
||||
@@ -5344,19 +5344,19 @@ describe('Parse.Query testing', () => {
|
||||
},
|
||||
});
|
||||
await parent.save();
|
||||
|
||||
|
||||
const query1 = await new Parse.Query('Parent')
|
||||
.containedIn('some.nested.key.child', [child])
|
||||
.find();
|
||||
|
||||
|
||||
expect(query1.length).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
it('queries nested key using matchesQuery', async () => {
|
||||
const child = new Parse.Object('Child');
|
||||
child.set('key', 'value');
|
||||
await child.save();
|
||||
|
||||
|
||||
const parent = new Parse.Object('Parent');
|
||||
parent.set('some', {
|
||||
nested: {
|
||||
@@ -5366,11 +5366,11 @@ describe('Parse.Query testing', () => {
|
||||
},
|
||||
});
|
||||
await parent.save();
|
||||
|
||||
|
||||
const query1 = await new Parse.Query('Parent')
|
||||
.matchesQuery('some.nested.key.child', new Parse.Query('Child').equalTo('key', 'value'))
|
||||
.find();
|
||||
|
||||
|
||||
expect(query1.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('Utils', () => {
|
||||
]
|
||||
for (const value of values) {
|
||||
expect(Utils.encodeForUrl(value.input)).toBe(value.output);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -48,10 +48,20 @@ module.exports = [
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"no-console": "off",
|
||||
"no-var": "error",
|
||||
"no-unused-vars": "off",
|
||||
indent: ["error", 2, { SwitchCase: 1 }],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"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",
|
||||
}
|
||||
"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