Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions api/tasks/tasks.methods.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ if (Meteor.isServer) {
});

it('can delete owned task', () => {
Meteor.call('removeTask', { taskId });
await Meteor.callAsync('removeTask', { taskId });

assert.equal(Tasks.find().count(), 0);
});

it("can't delete task if not authenticated", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it("can't delete task if not authenticated", () => {
it("can't delete task if not authenticated", async () => {

Could the codemod add the missing async on the context of the function where the await is added?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#18, sorry for reverting back very late, I have updated the codemod accordingly.

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.');
Expand All @@ -42,7 +42,7 @@ if (Meteor.isServer) {
it("can't delete task from another owner", () => {
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.');
Expand All @@ -52,7 +52,7 @@ if (Meteor.isServer) {

it('can change the status of a task', () => {
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);
Expand All @@ -63,7 +63,7 @@ if (Meteor.isServer) {
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.');
Expand All @@ -74,7 +74,7 @@ if (Meteor.isServer) {

it('can insert new tasks', () => {
const description = 'New Task';
Meteor.call('insertTask', { description });
await Meteor.callAsync('insertTask', { description });

const task = Tasks.findOne({ description });
assert.isNotNull(task);
Expand All @@ -85,7 +85,7 @@ if (Meteor.isServer) {
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.');
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/tasks/hooks/use-task-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export function useTaskItem() {
const toast = useToast();

function onMarkAsDone(_id) {
Meteor.call('toggleTaskDone', { taskId: _id });
await Meteor.callAsync('toggleTaskDone', { taskId: _id });
}

function onDelete(_id) {
try {
Meteor.call('removeTask', { taskId: _id });
await Meteor.callAsync('removeTask', { taskId: _id });
toast({
title: 'Task removed.',
status: 'success',
Expand Down