diff --git a/api/tasks/tasks.methods.tests.js b/api/tasks/tasks.methods.tests.js index cdd4dbd..b77270a 100644 --- a/api/tasks/tasks.methods.tests.js +++ b/api/tasks/tasks.methods.tests.js @@ -22,16 +22,16 @@ if (Meteor.isServer) { }); }); - it('can delete owned task', () => { - Meteor.call('removeTask', { taskId }); + it('can delete owned task', async () => { + await Meteor.callAsync('removeTask', { taskId }); assert.equal(Tasks.find().count(), 0); }); - it("can't delete task if not authenticated", () => { + it("can't delete task if not authenticated", async () => { mockLoggedUserId(null); try { - Meteor.call('removeTask', { taskId }); + await Meteor.callAsync('removeTask', { taskId }); } catch (error) { expect(error).to.be.instanceof(Error); expect(error.reason).to.be.equal('Not authorized.'); @@ -39,10 +39,10 @@ if (Meteor.isServer) { assert.equal(Tasks.find().count(), 1); }); - it("can't delete task from another owner", () => { + it("can't delete task from another owner", async () => { mockLoggedUserId(Random.id()); try { - Meteor.call('removeTask', { taskId }); + await Meteor.callAsync('removeTask', { taskId }); } catch (error) { expect(error).to.be.instanceof(Error); expect(error.reason).to.be.equal('Access denied.'); @@ -50,20 +50,20 @@ if (Meteor.isServer) { assert.equal(Tasks.find().count(), 1); }); - it('can change the status of a task', () => { + it('can change the status of a task', async () => { const originalTask = Tasks.findOne(taskId); - Meteor.call('toggleTaskDone', { taskId }); + await Meteor.callAsync('toggleTaskDone', { taskId }); const updatedTask = Tasks.findOne(taskId); assert.notEqual(updatedTask.done, originalTask.done); }); - it("can't change the status of a task from another owner", () => { + it("can't change the status of a task from another owner", async () => { mockLoggedUserId(Random.id()); const originalTask = Tasks.findOne(taskId); try { - Meteor.call('toggleTaskDone', { taskId }); + await Meteor.callAsync('toggleTaskDone', { taskId }); } catch (error) { expect(error).to.be.instanceof(Error); expect(error.reason).to.be.equal('Access denied.'); @@ -72,20 +72,20 @@ if (Meteor.isServer) { assert.equal(task.done, originalTask.done); }); - it('can insert new tasks', () => { + it('can insert new tasks', async () => { const description = 'New Task'; - Meteor.call('insertTask', { description }); + await Meteor.callAsync('insertTask', { description }); const task = Tasks.findOne({ description }); assert.isNotNull(task); assert.isTrue(task.description === description); }); - it("can't insert new tasks if not authenticated", () => { + it("can't insert new tasks if not authenticated", async () => { mockLoggedUserId(null); const description = 'New Task'; try { - Meteor.call('insertTask', { description }); + await Meteor.callAsync('insertTask', { description }); } catch (error) { expect(error).to.be.instanceof(Error); expect(error.reason).to.be.equal('Not authorized.'); diff --git a/ui/pages/tasks/hooks/use-task-item.jsx b/ui/pages/tasks/hooks/use-task-item.jsx index 68bfa76..87d7da5 100644 --- a/ui/pages/tasks/hooks/use-task-item.jsx +++ b/ui/pages/tasks/hooks/use-task-item.jsx @@ -4,13 +4,13 @@ import { Meteor } from 'meteor/meteor'; export function useTaskItem() { const toast = useToast(); - function onMarkAsDone(_id) { - Meteor.call('toggleTaskDone', { taskId: _id }); + async function onMarkAsDone(_id) { + await Meteor.callAsync('toggleTaskDone', { taskId: _id }); } - function onDelete(_id) { + async function onDelete(_id) { try { - Meteor.call('removeTask', { taskId: _id }); + await Meteor.callAsync('removeTask', { taskId: _id }); toast({ title: 'Task removed.', status: 'success',