fix test lint

This commit is contained in:
Matteo Pagliazzi
2019-10-08 20:45:38 +02:00
parent e37f4467f8
commit 85fb5f33aa
367 changed files with 6635 additions and 6080 deletions

View File

@@ -3,8 +3,9 @@ import {
translate as t,
} from '../../../../helpers/api-integration/v3';
let user, webhookToDelete;
let endpoint = '/user/webhook';
let user; let
webhookToDelete;
const endpoint = '/user/webhook';
describe('DELETE /user/webhook', () => {
beforeEach(async () => {
@@ -32,11 +33,11 @@ describe('DELETE /user/webhook', () => {
});
it('returns the remaining webhooks', async () => {
let [remainingWebhook] = await user.del(`${endpoint}/${webhookToDelete.id}`);
const [remainingWebhook] = await user.del(`${endpoint}/${webhookToDelete.id}`);
await user.sync();
let webhook = user.webhooks[0];
const webhook = user.webhooks[0];
expect(remainingWebhook.id).to.eql(webhook.id);
expect(remainingWebhook.url).to.eql(webhook.url);
@@ -48,7 +49,7 @@ describe('DELETE /user/webhook', () => {
await expect(user.del(`${endpoint}/id-that-does-not-exist`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('noWebhookWithId', {id: 'id-that-does-not-exist'}),
message: t('noWebhookWithId', { id: 'id-that-does-not-exist' }),
});
});
});

View File

@@ -22,7 +22,7 @@ describe('GET /user/webhook', () => {
});
it('returns users webhooks', async () => {
let response = await user.get('/user/webhook');
const response = await user.get('/user/webhook');
expect(response).to.eql(user.webhooks.map(w => {
w.createdAt = w.createdAt.toISOString();

View File

@@ -1,12 +1,13 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import apiError from '../../../../../website/server/libs/apiError';
describe('POST /user/webhook', () => {
let user, body;
let user; let
body;
beforeEach(async () => {
user = await generateUser();
@@ -41,7 +42,7 @@ describe('POST /user/webhook', () => {
it('defaults id to a uuid', async () => {
delete body.id;
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.id).to.exist;
});
@@ -59,7 +60,7 @@ describe('POST /user/webhook', () => {
it('defaults enabled to true', async () => {
delete body.enabled;
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.enabled).to.be.true;
});
@@ -67,7 +68,7 @@ describe('POST /user/webhook', () => {
it('can pass a label', async () => {
body.label = 'Custom Label';
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.label).to.equal('Custom Label');
});
@@ -75,7 +76,7 @@ describe('POST /user/webhook', () => {
it('defaults type to taskActivity', async () => {
delete body.type;
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.type).to.eql('taskActivity');
});
@@ -83,7 +84,7 @@ describe('POST /user/webhook', () => {
it('successfully adds the webhook', async () => {
expect(user.webhooks).to.eql([]);
let response = await user.post('/user/webhook', body);
const response = await user.post('/user/webhook', body);
expect(response.id).to.eql(body.id);
expect(response.type).to.eql(body.type);
@@ -94,7 +95,7 @@ describe('POST /user/webhook', () => {
expect(user.webhooks).to.not.eql([]);
let webhook = user.webhooks[0];
const webhook = user.webhooks[0];
expect(webhook.enabled).to.be.false;
expect(webhook.type).to.eql('taskActivity');
@@ -114,7 +115,7 @@ describe('POST /user/webhook', () => {
it('defaults taskActivity options', async () => {
body.type = 'taskActivity';
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.options).to.eql({
checklistScored: false,
@@ -135,7 +136,7 @@ describe('POST /user/webhook', () => {
scored: false,
};
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.options).to.eql({
checklistScored: true,
@@ -157,7 +158,7 @@ describe('POST /user/webhook', () => {
foo: 'bar',
};
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.options.foo).to.not.exist;
expect(webhook.options).to.eql({
@@ -169,7 +170,7 @@ describe('POST /user/webhook', () => {
});
});
['created', 'updated', 'deleted', 'scored'].forEach((option) => {
['created', 'updated', 'deleted', 'scored'].forEach(option => {
it(`requires taskActivity option ${option} to be a boolean`, async () => {
body.type = 'taskActivity';
body.options = {
@@ -190,7 +191,7 @@ describe('POST /user/webhook', () => {
groupId: generateUUID(),
};
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.options).to.eql({
groupId: body.options.groupId,
@@ -217,7 +218,7 @@ describe('POST /user/webhook', () => {
foo: 'bar',
};
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.options.foo).to.not.exist;
expect(webhook.options).to.eql({
@@ -231,7 +232,7 @@ describe('POST /user/webhook', () => {
foo: 'bar',
};
let webhook = await user.post('/user/webhook', body);
const webhook = await user.post('/user/webhook', body);
expect(webhook.options.foo).to.not.exist;
expect(webhook.options).to.eql({});

View File

@@ -1,12 +1,13 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID} from 'uuid';
import apiError from '../../../../../website/server/libs/apiError';
describe('PUT /user/webhook/:id', () => {
let user, webhookToUpdate;
let user; let
webhookToUpdate;
beforeEach(async () => {
user = await generateUser();
@@ -30,7 +31,7 @@ describe('PUT /user/webhook/:id', () => {
await expect(user.put('/user/webhook/id-that-does-not-exist')).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('noWebhookWithId', {id: 'id-that-does-not-exist'}),
message: t('noWebhookWithId', { id: 'id-that-does-not-exist' }),
});
});
@@ -43,16 +44,18 @@ describe('PUT /user/webhook/:id', () => {
});
it('updates a webhook', async () => {
let url = 'http://a-new-url.com';
let type = 'groupChatReceived';
let label = 'New Label';
let options = { groupId: generateUUID() };
const url = 'http://a-new-url.com';
const type = 'groupChatReceived';
const label = 'New Label';
const options = { groupId: generateUUID() };
await user.put(`/user/webhook/${webhookToUpdate.id}`, {url, type, options, label});
await user.put(`/user/webhook/${webhookToUpdate.id}`, {
url, type, options, label,
});
await user.sync();
let webhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id);
const webhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id);
expect(webhook.url).to.equal(url);
expect(webhook.label).to.equal(label);
@@ -61,11 +64,11 @@ describe('PUT /user/webhook/:id', () => {
});
it('returns the updated webhook', async () => {
let url = 'http://a-new-url.com';
let type = 'groupChatReceived';
let options = { groupId: generateUUID() };
const url = 'http://a-new-url.com';
const type = 'groupChatReceived';
const options = { groupId: generateUUID() };
let response = await user.put(`/user/webhook/${webhookToUpdate.id}`, {url, type, options});
const response = await user.put(`/user/webhook/${webhookToUpdate.id}`, { url, type, options });
expect(response.url).to.eql(url);
expect(response.type).to.eql(type);
@@ -73,27 +76,27 @@ describe('PUT /user/webhook/:id', () => {
});
it('cannot update the id', async () => {
let id = generateUUID();
let url = 'http://a-new-url.com';
const id = generateUUID();
const url = 'http://a-new-url.com';
await user.put(`/user/webhook/${webhookToUpdate.id}`, {url, id});
await user.put(`/user/webhook/${webhookToUpdate.id}`, { url, id });
await user.sync();
let webhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id);
const webhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id);
expect(webhook.id).to.eql(webhookToUpdate.id);
expect(webhook.url).to.eql(url);
});
it('can update taskActivity options', async () => {
let type = 'taskActivity';
let options = {
const type = 'taskActivity';
const options = {
updated: false,
deleted: true,
};
let webhook = await user.put(`/user/webhook/${webhookToUpdate.id}`, {type, options});
const webhook = await user.put(`/user/webhook/${webhookToUpdate.id}`, { type, options });
expect(webhook.options).to.eql({
checklistScored: false, // starting value
@@ -105,14 +108,14 @@ describe('PUT /user/webhook/:id', () => {
});
it('errors if taskActivity option is not a boolean', async () => {
let type = 'taskActivity';
let options = {
const type = 'taskActivity';
const options = {
created: 'not a boolean',
updated: false,
deleted: true,
};
await expect(user.put(`/user/webhook/${webhookToUpdate.id}`, {type, options})).to.eventually.be.rejected.and.eql({
await expect(user.put(`/user/webhook/${webhookToUpdate.id}`, { type, options })).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('webhookBooleanOption', { option: 'created' }),
@@ -120,12 +123,12 @@ describe('PUT /user/webhook/:id', () => {
});
it('errors if groupChatRecieved groupId option is not a uuid', async () => {
let type = 'groupChatReceived';
let options = {
const type = 'groupChatReceived';
const options = {
groupId: 'not-a-uuid',
};
await expect(user.put(`/user/webhook/${webhookToUpdate.id}`, {type, options})).to.eventually.be.rejected.and.eql({
await expect(user.put(`/user/webhook/${webhookToUpdate.id}`, { type, options })).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: apiError('groupIdRequired'),