Files
habitica/test/common/ops/updateTask.js
Matteo Pagliazzi 6380161321 Api v3 Migration (WIP) (#7131)
* v3 migration: remove old code and polish user migration

* v3 migration: start to work on challenges

* wip v3 migration

* wip v3 migration: fix _id -> id for reminders, tags and checklists
2016-04-30 18:34:16 +02:00

54 lines
1.1 KiB
JavaScript

import updateTask from '../../../common/script/ops/updateTask';
import {
generateHabit,
} from '../../helpers/common.helper';
describe('shared.ops.updateTask', () => {
it('updates a task', () => {
let now = new Date();
let habit = generateHabit({
tags: [
'123',
'456',
],
reminders: [{
id: '123',
startDate: now,
time: now,
}],
});
let [res] = updateTask(habit, {
body: {
text: 'updated',
id: '123',
_id: '123',
type: 'todo',
tags: ['678'],
checklist: [{
completed: false,
text: 'item',
id: '123',
}],
},
});
expect(res.id).to.not.equal('123');
expect(res._id).to.not.equal('123');
expect(res.type).to.equal('habit');
expect(res.text).to.equal('updated');
expect(res.checklist).to.eql([{
completed: false,
text: 'item',
id: '123',
}]);
expect(res.reminders).to.eql([{
id: '123',
startDate: now,
time: now,
}]);
expect(res.tags).to.eql(['678']);
});
});