mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix tests
This commit is contained in:
@@ -58,8 +58,6 @@ describe('POST /tasks', () => {
|
|||||||
|
|
||||||
it('ignores setting challenge field');
|
it('ignores setting challenge field');
|
||||||
|
|
||||||
it('ignores setting value field');
|
|
||||||
|
|
||||||
it('ignores setting completed field');
|
it('ignores setting completed field');
|
||||||
|
|
||||||
it('ignores setting streak field');
|
it('ignores setting streak field');
|
||||||
@@ -127,7 +125,7 @@ describe('POST /tasks', () => {
|
|||||||
expect(task.type).to.eql('daily');
|
expect(task.type).to.eql('daily');
|
||||||
expect(task.frequency).to.eql('daily');
|
expect(task.frequency).to.eql('daily');
|
||||||
expect(task.everyX).to.eql(5);
|
expect(task.everyX).to.eql(5);
|
||||||
expect(task.startDate).to.eql(now);
|
expect(new Date(task.startDate)).to.eql(now);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,7 @@ describe('PUT /tasks/:id', () => {
|
|||||||
// task = createdTask
|
// task = createdTask
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an error if req.body.type is not valid', () => {
|
it('ignores setting type field');
|
||||||
return expect(api.put(`/tasks/${task._id}`, {
|
|
||||||
type: 'habitF',
|
|
||||||
})).to.eventually.be.rejected.and.eql({
|
|
||||||
code: 400,
|
|
||||||
error: 'BadRequest',
|
|
||||||
message: t('invalidReqParams'),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('ignores setting userId field');
|
it('ignores setting userId field');
|
||||||
|
|
||||||
@@ -57,8 +49,13 @@ describe('PUT /tasks/:id', () => {
|
|||||||
let habit;
|
let habit;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// create existing habit
|
return api.post('/tasks', {
|
||||||
// habit = createdHabit;
|
text: 'test habit',
|
||||||
|
type: 'habit',
|
||||||
|
notes: 1976,
|
||||||
|
}).then((createdHabit) => {
|
||||||
|
habit = createdHabit;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates a habit', () => {
|
it('updates a habit', () => {
|
||||||
@@ -80,8 +77,13 @@ describe('PUT /tasks/:id', () => {
|
|||||||
let todo;
|
let todo;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// create existing todo
|
return api.post('/tasks', {
|
||||||
// todo = createdTodo;
|
text: 'test todo',
|
||||||
|
type: 'todo',
|
||||||
|
notes: 1976,
|
||||||
|
}).then((createdTodo) => {
|
||||||
|
todo = createdTodo;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates a todo', () => {
|
it('updates a todo', () => {
|
||||||
@@ -101,8 +103,13 @@ describe('PUT /tasks/:id', () => {
|
|||||||
let daily;
|
let daily;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// create existing daily
|
return api.post('/tasks', {
|
||||||
// daily = createdDaily;
|
text: 'test daily',
|
||||||
|
type: 'daily',
|
||||||
|
notes: 1976,
|
||||||
|
}).then((createdDaily) => {
|
||||||
|
daily = createdDaily;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates a daily', () => {
|
it('updates a daily', () => {
|
||||||
@@ -134,8 +141,14 @@ describe('PUT /tasks/:id', () => {
|
|||||||
let reward;
|
let reward;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// create existing reward
|
return api.post('/tasks', {
|
||||||
// reward = createdReward;
|
text: 'test reward',
|
||||||
|
type: 'reward',
|
||||||
|
notes: 1976,
|
||||||
|
value: 10,
|
||||||
|
}).then((createdReward) => {
|
||||||
|
reward = createdReward;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates a reward', () => {
|
it('updates a reward', () => {
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ export let TaskSchema = new Schema({
|
|||||||
}, discriminatorOptions));
|
}, discriminatorOptions));
|
||||||
|
|
||||||
TaskSchema.plugin(baseModel, {
|
TaskSchema.plugin(baseModel, {
|
||||||
noSet: ['challenge', 'userId', 'value', 'completed', 'history', 'streak', 'dateCompleted'], // TODO checklist fields editable?
|
// TODO checklist fields editable?
|
||||||
|
// TODO value should be settable only for rewards
|
||||||
|
noSet: ['challenge', 'userId', 'completed', 'history', 'streak', 'dateCompleted'],
|
||||||
private: [],
|
private: [],
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user