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

@@ -1,10 +1,10 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
let user;
@@ -27,7 +27,7 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
});
it('fails on checklist item not found', async () => {
let createdTask = await user.post(`/tasks/challenge/${challenge._id}`, {
const createdTask = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'daily',
text: 'daily with checklist',
});
@@ -40,17 +40,17 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
});
it('returns error when user is not a member of the challenge', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'daily',
text: 'Daily with checklist',
});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {
const savedTask = await user.post(`/tasks/${task._id}/checklist`, {
text: 'Checklist Item 1',
completed: false,
});
let anotherUser = await generateUser();
const anotherUser = await generateUser();
await expect(anotherUser.del(`/tasks/${task._id}/checklist/${savedTask.checklist[0].id}`))
.to.eventually.be.rejected.and.eql({
@@ -61,12 +61,12 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
});
it('deletes a checklist item from a daily', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'daily',
text: 'Daily with checklist',
});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {text: 'Checklist Item 1', completed: false});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, { text: 'Checklist Item 1', completed: false });
await user.del(`/tasks/${task._id}/checklist/${savedTask.checklist[0].id}`);
savedTask = await user.get(`/tasks/${task._id}`);
@@ -75,12 +75,12 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
});
it('deletes a checklist item from a todo', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'todo',
text: 'Todo with checklist',
});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {text: 'Checklist Item 1', completed: false});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, { text: 'Checklist Item 1', completed: false });
await user.del(`/tasks/${task._id}/checklist/${savedTask.checklist[0].id}`);
savedTask = await user.get(`/tasks/${task._id}`);
@@ -89,7 +89,7 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
});
it('does not work with habits', async () => {
let habit = await user.post(`/tasks/challenge/${challenge._id}`, {
const habit = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'habit',
text: 'habit with checklist',
});
@@ -102,7 +102,7 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
});
it('does not work with rewards', async () => {
let reward = await user.post(`/tasks/challenge/${challenge._id}`, {
const reward = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'reward',
text: 'reward with checklist',
});

View File

@@ -1,3 +1,4 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
generateGroup,
@@ -5,7 +6,6 @@ import {
sleep,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('DELETE /tasks/:id', () => {
let user;
@@ -36,7 +36,7 @@ describe('DELETE /tasks/:id', () => {
});
it('returns error when user is not leader of the challenge', async () => {
let anotherUser = await generateUser();
const anotherUser = await generateUser();
await expect(anotherUser.del(`/tasks/${task._id}`)).to.eventually.be.rejected.and.eql({
code: 401,
@@ -71,8 +71,9 @@ describe('DELETE /tasks/:id', () => {
type: 'habit',
});
let anotherUserWithNewChallengeTask = await anotherUser.get('/user');
anotherUsersNewChallengeTaskID = anotherUserWithNewChallengeTask.tasksOrder.habits[0];
const anotherUserWithNewChallengeTask = await anotherUser.get('/user');
anotherUsersNewChallengeTaskID = anotherUserWithNewChallengeTask // eslint-disable-line prefer-destructuring, max-len
.tasksOrder.habits[0];
});
it('returns error when user attempts to delete an active challenge task', async () => {
@@ -96,7 +97,8 @@ describe('DELETE /tasks/:id', () => {
});
});
// TODO for some reason this test fails on TravisCI, review after mongodb indexes have been added
// TODO for some reason this test fails on TravisCI,
// review after mongodb indexes have been added
xit('allows user to delete challenge task after challenge task is broken', async () => {
await expect(user.del(`/tasks/${newChallengeTask._id}`));

View File

@@ -1,20 +1,20 @@
import { v4 as generateUUID } from 'uuid';
import { each } from 'lodash';
import {
generateUser,
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { each } from 'lodash';
describe('GET /tasks/challenge/:challengeId', () => {
let user;
let guild;
let challenge;
let task;
let tasks = [];
const tasks = [];
let challengeWithTask;
let tasksToTest = {
const tasksToTest = {
habit: {
text: 'test habit',
type: 'habit',
@@ -46,7 +46,7 @@ describe('GET /tasks/challenge/:challengeId', () => {
});
it('returns error when challenge is not found', async () => {
let dummyId = generateUUID();
const dummyId = generateUUID();
await expect(user.get(`/tasks/challenge/${dummyId}`)).to.eventually.be.rejected.and.eql({
code: 404,
@@ -64,17 +64,17 @@ describe('GET /tasks/challenge/:challengeId', () => {
});
it('gets challenge tasks', async () => {
let getTask = await user.get(`/tasks/challenge/${challengeWithTask._id}`);
const getTask = await user.get(`/tasks/challenge/${challengeWithTask._id}`);
expect(getTask).to.eql(tasks);
});
it('gets challenge tasks filtered by type', async () => {
let challengeTasks = await user.get(`/tasks/challenge/${challengeWithTask._id}?type=${task.type}s`);
const challengeTasks = await user.get(`/tasks/challenge/${challengeWithTask._id}?type=${task.type}s`);
expect(challengeTasks).to.eql([task]);
});
it('cannot get a task owned by someone else', async () => {
let anotherUser = await generateUser();
const anotherUser = await generateUser();
await expect(anotherUser.get(`/tasks/challenge/${challengeWithTask._id}`)).to.eventually.be.rejected.and.eql({
code: 404,

View File

@@ -1,10 +1,10 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /tasks/:taskId/checklist/', () => {
let user;
@@ -29,12 +29,12 @@ describe('POST /tasks/:taskId/checklist/', () => {
});
it('returns error when user is not a member of the challenge', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'daily',
text: 'Daily with checklist',
});
let anotherUser = await generateUser();
const anotherUser = await generateUser();
await expect(anotherUser.post(`/tasks/${task._id}/checklist`, {
text: 'Checklist Item 1',
@@ -49,12 +49,12 @@ describe('POST /tasks/:taskId/checklist/', () => {
});
it('adds a checklist item to a daily', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'daily',
text: 'Daily with checklist',
});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {
const savedTask = await user.post(`/tasks/${task._id}/checklist`, {
text: 'Checklist Item 1',
ignored: false,
_id: 123,
@@ -69,12 +69,12 @@ describe('POST /tasks/:taskId/checklist/', () => {
});
it('adds a checklist item to a todo', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'todo',
text: 'Todo with checklist',
});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {
const savedTask = await user.post(`/tasks/${task._id}/checklist`, {
text: 'Checklist Item 1',
ignored: false,
_id: 123,
@@ -89,7 +89,7 @@ describe('POST /tasks/:taskId/checklist/', () => {
});
it('does not add a checklist to habits', async () => {
let habit = await user.post(`/tasks/challenge/${challenge._id}`, {
const habit = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'habit',
text: 'habit with checklist',
});
@@ -104,7 +104,7 @@ describe('POST /tasks/:taskId/checklist/', () => {
});
it('does not add a checklist to rewards', async () => {
let reward = await user.post(`/tasks/challenge/${challenge._id}`, {
const reward = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'reward',
text: 'reward with checklist',
});

View File

@@ -1,11 +1,11 @@
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
import {
generateUser,
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
describe('POST /tasks/challenge/:challengeId', () => {
let user;
@@ -17,14 +17,14 @@ describe('POST /tasks/challenge/:challengeId', () => {
}
beforeEach(async () => {
user = await generateUser({balance: 1});
user = await generateUser({ balance: 1 });
guild = await generateGroup(user);
challenge = await generateChallenge(user, guild);
await user.post(`/challenges/${challenge._id}/join`);
});
it('returns error when challenge is not found', async () => {
let fakeChallengeId = generateUUID();
const fakeChallengeId = generateUUID();
await expect(user.post(`/tasks/challenge/${fakeChallengeId}`, {
text: 'test habit',
@@ -41,7 +41,7 @@ describe('POST /tasks/challenge/:challengeId', () => {
it('allows leader to add tasks to a challenge when not a member', async () => {
await user.post(`/challenges/${challenge._id}/leave`);
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
text: 'test habit',
type: 'habit',
up: false,
@@ -49,14 +49,14 @@ describe('POST /tasks/challenge/:challengeId', () => {
notes: 1976,
});
let {tasksOrder} = await user.get(`/challenges/${challenge._id}`);
const { tasksOrder } = await user.get(`/challenges/${challenge._id}`);
expect(tasksOrder.habits).to.include(task.id);
});
it('allows non-leader admin to add tasks to a challenge when not a member', async () => {
const admin = await generateUser({'contributor.admin': true});
let task = await admin.post(`/tasks/challenge/${challenge._id}`, {
const admin = await generateUser({ 'contributor.admin': true });
const task = await admin.post(`/tasks/challenge/${challenge._id}`, {
text: 'test habit from admin',
type: 'habit',
up: false,
@@ -64,7 +64,7 @@ describe('POST /tasks/challenge/:challengeId', () => {
notes: 1976,
});
let {tasksOrder} = await user.get(`/challenges/${challenge._id}`);
const { tasksOrder } = await user.get(`/challenges/${challenge._id}`);
expect(tasksOrder.habits).to.include(task.id);
});
@@ -82,7 +82,7 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
it('returns error when non leader tries to edit challenge', async () => {
let userThatIsNotLeaderOfChallenge = await generateUser({
const userThatIsNotLeaderOfChallenge = await generateUser({
challenges: [challenge._id],
});
@@ -100,17 +100,17 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
it('creates a habit', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
text: 'test habit',
type: 'habit',
up: false,
down: true,
notes: 1976,
});
let challengeWithTask = await user.get(`/challenges/${challenge._id}`);
const challengeWithTask = await user.get(`/challenges/${challenge._id}`);
let memberTasks = await user.get('/tasks/user');
let userChallengeTask = find(memberTasks, findUserChallengeTask);
const memberTasks = await user.get('/tasks/user');
const userChallengeTask = find(memberTasks, findUserChallengeTask);
expect(challengeWithTask.tasksOrder.habits.indexOf(task._id)).to.be.above(-1);
expect(task.challenge.id).to.equal(challenge._id);
@@ -124,15 +124,15 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
it('creates a todo', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
text: 'test todo',
type: 'todo',
notes: 1976,
});
let challengeWithTask = await user.get(`/challenges/${challenge._id}`);
const challengeWithTask = await user.get(`/challenges/${challenge._id}`);
let memberTasks = await user.get('/tasks/user');
let userChallengeTask = find(memberTasks, findUserChallengeTask);
const memberTasks = await user.get('/tasks/user');
const userChallengeTask = find(memberTasks, findUserChallengeTask);
expect(challengeWithTask.tasksOrder.todos.indexOf(task._id)).to.be.above(-1);
expect(task.challenge.id).to.equal(challenge._id);
@@ -144,8 +144,8 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
it('creates a daily', async () => {
let now = new Date();
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const now = new Date();
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
text: 'test daily',
type: 'daily',
notes: 1976,
@@ -153,10 +153,10 @@ describe('POST /tasks/challenge/:challengeId', () => {
everyX: 5,
startDate: now,
});
let challengeWithTask = await user.get(`/challenges/${challenge._id}`);
const challengeWithTask = await user.get(`/challenges/${challenge._id}`);
let memberTasks = await user.get('/tasks/user');
let userChallengeTask = find(memberTasks, findUserChallengeTask);
const memberTasks = await user.get('/tasks/user');
const userChallengeTask = find(memberTasks, findUserChallengeTask);
expect(challengeWithTask.tasksOrder.dailys.indexOf(task._id)).to.be.above(-1);
expect(task.challenge.id).to.equal(challenge._id);

View File

@@ -1,10 +1,10 @@
import { find } from 'lodash';
import {
generateUser,
generateGroup,
generateChallenge,
sleep,
} from '../../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /tasks/:id/score/:direction', () => {
let user;
@@ -29,16 +29,16 @@ describe('POST /tasks/:id/score/:direction', () => {
type: 'habit',
});
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.habits[0];
const updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.habits[0]; // eslint-disable-line prefer-destructuring, max-len
});
it('scores and adds history', async () => {
await user.post(`/tasks/${usersChallengeTaskId}/score/up`);
let tasks = await user.get(`/tasks/challenge/${challenge._id}`);
let task = find(tasks, {_id: habit._id});
previousTaskHistory = task.history[0];
const tasks = await user.get(`/tasks/challenge/${challenge._id}`);
const task = find(tasks, { _id: habit._id });
previousTaskHistory = task.history[0]; // eslint-disable-line prefer-destructuring, max-len
expect(task.value).to.equal(1);
expect(task.history).to.have.lengthOf(1);
@@ -47,8 +47,8 @@ describe('POST /tasks/:id/score/:direction', () => {
it('should update the history', async () => {
await user.post(`/tasks/${usersChallengeTaskId}/score/up`);
let tasks = await user.get(`/tasks/challenge/${challenge._id}`);
let task = find(tasks, {_id: habit._id});
const tasks = await user.get(`/tasks/challenge/${challenge._id}`);
const task = find(tasks, { _id: habit._id });
expect(task.history).to.have.lengthOf(1);
expect(task.history[0].date).to.not.equal(previousTaskHistory.date);
@@ -67,23 +67,23 @@ describe('POST /tasks/:id/score/:direction', () => {
type: 'daily',
});
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.dailys[0];
const updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.dailys[0]; // eslint-disable-line prefer-destructuring, max-len
});
it('it scores and adds history', async () => {
await user.post(`/tasks/${usersChallengeTaskId}/score/up`);
let tasks = await user.get(`/tasks/challenge/${challenge._id}`);
let task = find(tasks, {_id: daily._id});
previousTaskHistory = task.history[0];
const tasks = await user.get(`/tasks/challenge/${challenge._id}`);
const task = find(tasks, { _id: daily._id });
previousTaskHistory = task.history[0]; // eslint-disable-line prefer-destructuring
expect(task.history).to.have.lengthOf(1);
expect(task.value).to.equal(1);
});
it('should update the history', async () => {
let newCron = new Date(2015, 11, 20);
const newCron = new Date(2015, 11, 20);
await user.post('/debug/set-cron', {
lastCron: newCron,
@@ -92,8 +92,8 @@ describe('POST /tasks/:id/score/:direction', () => {
await user.post('/cron');
await user.post(`/tasks/${usersChallengeTaskId}/score/up`);
let tasks = await user.get(`/tasks/challenge/${challenge._id}`);
let task = find(tasks, {_id: daily._id});
const tasks = await user.get(`/tasks/challenge/${challenge._id}`);
const task = find(tasks, { _id: daily._id });
expect(task.history).to.have.lengthOf(1);
expect(task.history[0].date).to.not.equal(previousTaskHistory.date);
@@ -111,15 +111,15 @@ describe('POST /tasks/:id/score/:direction', () => {
type: 'todo',
});
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.todos[0];
const updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.todos[0]; // eslint-disable-line prefer-destructuring, max-len
});
it('scores but does not add history', async () => {
await user.post(`/tasks/${usersChallengeTaskId}/score/up`);
let tasks = await user.get(`/tasks/challenge/${challenge._id}`);
let task = find(tasks, {_id: todo._id});
const tasks = await user.get(`/tasks/challenge/${challenge._id}`);
const task = find(tasks, { _id: todo._id });
expect(task.history).to.not.exist;
expect(task.value).to.equal(1);
@@ -136,15 +136,15 @@ describe('POST /tasks/:id/score/:direction', () => {
type: 'reward',
});
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.todos[0];
const updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.todos[0]; // eslint-disable-line prefer-destructuring, max-len
});
it('does not score', async () => {
await user.post(`/tasks/${usersChallengeTaskId}/score/up`);
let tasks = await user.get(`/tasks/challenge/${challenge._id}`);
let task = find(tasks, {_id: reward._id});
const tasks = await user.get(`/tasks/challenge/${challenge._id}`);
const task = find(tasks, { _id: reward._id });
expect(task.history).to.not.exist;
expect(task.value).to.equal(0);

View File

@@ -1,10 +1,10 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('PUT /tasks/:id', () => {
let user;
@@ -42,7 +42,7 @@ describe('PUT /tasks/:id', () => {
});
it('returns error when user is not a member of the challenge', async () => {
let anotherUser = await generateUser();
const anotherUser = await generateUser();
await expect(anotherUser.put(`/tasks/${task._id}`, {
text: 'some new text',
@@ -80,7 +80,7 @@ describe('PUT /tasks/:id', () => {
it(`ignores setting _id, type, userId, history, createdAt,
updatedAt, challenge, completed, streak,
dateCompleted fields`, async () => {
let savedTask = await user.put(`/tasks/${task._id}`, {
const savedTask = await user.put(`/tasks/${task._id}`, {
_id: 123,
type: 'daily',
userId: 123,
@@ -108,7 +108,7 @@ describe('PUT /tasks/:id', () => {
});
it('ignores invalid fields', async () => {
let savedTask = await user.put(`/tasks/${task._id}`, {
const savedTask = await user.put(`/tasks/${task._id}`, {
notValid: true,
});
@@ -128,7 +128,7 @@ describe('PUT /tasks/:id', () => {
});
it('updates a habit', async () => {
let savedHabit = await user.put(`/tasks/${habit._id}`, {
const savedHabit = await user.put(`/tasks/${habit._id}`, {
text: 'some new text',
up: false,
down: false,
@@ -171,7 +171,7 @@ describe('PUT /tasks/:id', () => {
});
it('updates a todo', async () => {
let savedTodo = await user.put(`/tasks/${todo._id}`, {
const savedTodo = await user.put(`/tasks/${todo._id}`, {
text: 'some new text',
notes: 'some new notes',
});
@@ -183,14 +183,14 @@ describe('PUT /tasks/:id', () => {
it('can update checklists (replace it)', async () => {
await user.put(`/tasks/${todo._id}`, {
checklist: [
{text: 123, completed: false},
{text: 456, completed: true},
{ text: 123, completed: false },
{ text: 456, completed: true },
],
});
let savedTodo = await user.put(`/tasks/${todo._id}`, {
const savedTodo = await user.put(`/tasks/${todo._id}`, {
checklist: [
{text: 789, completed: false},
{ text: 789, completed: false },
],
});
@@ -200,12 +200,12 @@ describe('PUT /tasks/:id', () => {
});
it('can update tags (replace them)', async () => {
let finalUUID = generateUUID();
const finalUUID = generateUUID();
await user.put(`/tasks/${todo._id}`, {
tags: [generateUUID(), generateUUID()],
});
let savedTodo = await user.put(`/tasks/${todo._id}`, {
const savedTodo = await user.put(`/tasks/${todo._id}`, {
tags: [finalUUID],
});
@@ -226,7 +226,7 @@ describe('PUT /tasks/:id', () => {
});
it('updates a daily', async () => {
let savedDaily = await user.put(`/tasks/${daily._id}`, {
const savedDaily = await user.put(`/tasks/${daily._id}`, {
text: 'some new text',
notes: 'some new notes',
frequency: 'daily',
@@ -242,14 +242,14 @@ describe('PUT /tasks/:id', () => {
it('can update checklists (replace it)', async () => {
await user.put(`/tasks/${daily._id}`, {
checklist: [
{text: 123, completed: false},
{text: 456, completed: true},
{ text: 123, completed: false },
{ text: 456, completed: true },
],
});
let savedDaily = await user.put(`/tasks/${daily._id}`, {
const savedDaily = await user.put(`/tasks/${daily._id}`, {
checklist: [
{text: 789, completed: false},
{ text: 789, completed: false },
],
});
@@ -259,12 +259,12 @@ describe('PUT /tasks/:id', () => {
});
it('can update tags (replace them)', async () => {
let finalUUID = generateUUID();
const finalUUID = generateUUID();
await user.put(`/tasks/${daily._id}`, {
tags: [generateUUID(), generateUUID()],
});
let savedDaily = await user.put(`/tasks/${daily._id}`, {
const savedDaily = await user.put(`/tasks/${daily._id}`, {
tags: [finalUUID],
});
@@ -277,7 +277,7 @@ describe('PUT /tasks/:id', () => {
frequency: 'daily',
});
let savedDaily = await user.put(`/tasks/${daily._id}`, {
const savedDaily = await user.put(`/tasks/${daily._id}`, {
repeat: {
m: false,
su: false,
@@ -300,7 +300,7 @@ describe('PUT /tasks/:id', () => {
frequency: 'weekly',
});
let savedDaily = await user.put(`/tasks/${daily._id}`, {
const savedDaily = await user.put(`/tasks/${daily._id}`, {
everyX: 5,
});
@@ -308,7 +308,7 @@ describe('PUT /tasks/:id', () => {
});
it('defaults startDate to today if none date object is passed in', async () => {
let savedDaily = await user.put(`/tasks/${daily._id}`, {
const savedDaily = await user.put(`/tasks/${daily._id}`, {
frequency: 'weekly',
});
@@ -329,7 +329,7 @@ describe('PUT /tasks/:id', () => {
});
it('updates a reward', async () => {
let savedReward = await user.put(`/tasks/${reward._id}`, {
const savedReward = await user.put(`/tasks/${reward._id}`, {
text: 'some new text',
notes: 'some new notes',
value: 11,
@@ -341,7 +341,7 @@ describe('PUT /tasks/:id', () => {
});
it('requires value to be coerced into a number', async () => {
let savedReward = await user.put(`/tasks/${reward._id}`, {
const savedReward = await user.put(`/tasks/${reward._id}`, {
value: '100',
});

View File

@@ -1,10 +1,10 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('PUT /tasks/:taskId/checklist/:itemId', () => {
let user;
@@ -19,7 +19,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('fails on task not found', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'todo',
text: 'Todo with checklist',
});
@@ -37,17 +37,17 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('returns error when user is not a member of the challenge', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'todo',
text: 'Todo with checklist',
});
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {
const savedTask = await user.post(`/tasks/${task._id}/checklist`, {
text: 'Checklist Item 1',
completed: false,
});
let anotherUser = await generateUser();
const anotherUser = await generateUser();
await expect(anotherUser.put(`/tasks/${task._id}/checklist/${savedTask.checklist[0].id}`, {
text: 'updated',
@@ -62,7 +62,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('updates a checklist item on dailies', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'daily',
text: 'Daily with checklist',
});
@@ -85,7 +85,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('updates a checklist item on todos', async () => {
let task = await user.post(`/tasks/challenge/${challenge._id}`, {
const task = await user.post(`/tasks/challenge/${challenge._id}`, {
type: 'todo',
text: 'Todo with checklist',
});
@@ -108,7 +108,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('fails on habits', async () => {
let habit = await user.post('/tasks/user', {
const habit = await user.post('/tasks/user', {
type: 'habit',
text: 'habit with checklist',
});
@@ -121,7 +121,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('fails on rewards', async () => {
let reward = await user.post('/tasks/user', {
const reward = await user.post('/tasks/user', {
type: 'reward',
text: 'reward with checklist',
});
@@ -142,7 +142,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
});
it('fails on checklist item not found', async () => {
let createdTask = await user.post('/tasks/user', {
const createdTask = await user.post('/tasks/user', {
type: 'daily',
text: 'daily with checklist',
});