mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
@@ -25,6 +25,21 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
|
||||
expect(savedTask.checklist.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('deletes a checklist item using task alias', async () => {
|
||||
let task = await user.post('/tasks/user', {
|
||||
type: 'daily',
|
||||
text: 'Daily with checklist',
|
||||
alias: 'daily-with-alias',
|
||||
});
|
||||
|
||||
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {text: 'Checklist Item 1', completed: false});
|
||||
|
||||
await user.del(`/tasks/${task.alias}/checklist/${savedTask.checklist[0].id}`);
|
||||
savedTask = await user.get(`/tasks/${task._id}`);
|
||||
|
||||
expect(savedTask.checklist.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('does not work with habits', async () => {
|
||||
let habit = await user.post('/tasks/user', {
|
||||
type: 'habit',
|
||||
|
||||
@@ -31,6 +31,27 @@ describe('POST /tasks/:taskId/checklist/', () => {
|
||||
expect(savedTask.checklist[0].ignored).to.be.an('undefined');
|
||||
});
|
||||
|
||||
it('can use a alias to add checklist', async () => {
|
||||
let task = await user.post('/tasks/user', {
|
||||
type: 'daily',
|
||||
text: 'Daily with checklist',
|
||||
alias: 'task-with-shortname',
|
||||
});
|
||||
|
||||
let savedTask = await user.post(`/tasks/${task.alias}/checklist`, {
|
||||
text: 'Checklist Item 1',
|
||||
ignored: false,
|
||||
_id: 123,
|
||||
});
|
||||
|
||||
expect(savedTask.checklist.length).to.equal(1);
|
||||
expect(savedTask.checklist[0].text).to.equal('Checklist Item 1');
|
||||
expect(savedTask.checklist[0].completed).to.equal(false);
|
||||
expect(savedTask.checklist[0].id).to.be.a('string');
|
||||
expect(savedTask.checklist[0].id).to.not.equal('123');
|
||||
expect(savedTask.checklist[0].ignored).to.be.an('undefined');
|
||||
});
|
||||
|
||||
it('does not add a checklist to habits', async () => {
|
||||
let habit = await user.post('/tasks/user', {
|
||||
type: 'habit',
|
||||
|
||||
@@ -28,6 +28,24 @@ describe('POST /tasks/:taskId/checklist/:itemId/score', () => {
|
||||
expect(savedTask.checklist[0].completed).to.equal(true);
|
||||
});
|
||||
|
||||
it('can use a alias to score a checklist item', async () => {
|
||||
let task = await user.post('/tasks/user', {
|
||||
type: 'daily',
|
||||
text: 'Daily with checklist',
|
||||
alias: 'daily-with-shortname',
|
||||
});
|
||||
|
||||
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {
|
||||
text: 'Checklist Item 1',
|
||||
completed: false,
|
||||
});
|
||||
|
||||
savedTask = await user.post(`/tasks/${task.alias}/checklist/${savedTask.checklist[0].id}/score`);
|
||||
|
||||
expect(savedTask.checklist.length).to.equal(1);
|
||||
expect(savedTask.checklist[0].completed).to.equal(true);
|
||||
});
|
||||
|
||||
it('fails on habits', async () => {
|
||||
let habit = await user.post('/tasks/user', {
|
||||
type: 'habit',
|
||||
|
||||
@@ -34,6 +34,30 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
|
||||
expect(savedTask.checklist[0].id).to.not.equal('123');
|
||||
});
|
||||
|
||||
it('updates a checklist item using task alias', async () => {
|
||||
let task = await user.post('/tasks/user', {
|
||||
type: 'daily',
|
||||
text: 'Daily with checklist',
|
||||
alias: 'daily-with-shortname',
|
||||
});
|
||||
|
||||
let savedTask = await user.post(`/tasks/${task._id}/checklist`, {
|
||||
text: 'Checklist Item 1',
|
||||
completed: false,
|
||||
});
|
||||
|
||||
savedTask = await user.put(`/tasks/${task.alias}/checklist/${savedTask.checklist[0].id}`, {
|
||||
text: 'updated',
|
||||
completed: true,
|
||||
_id: 123, // ignored
|
||||
});
|
||||
|
||||
expect(savedTask.checklist.length).to.equal(1);
|
||||
expect(savedTask.checklist[0].text).to.equal('updated');
|
||||
expect(savedTask.checklist[0].completed).to.equal(true);
|
||||
expect(savedTask.checklist[0].id).to.not.equal('123');
|
||||
});
|
||||
|
||||
it('fails on habits', async () => {
|
||||
let habit = await user.post('/tasks/user', {
|
||||
type: 'habit',
|
||||
|
||||
Reference in New Issue
Block a user