Skip to content

Instantly share code, notes, and snippets.

@dai-shi
Created March 28, 2016 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dai-shi/63a3114c0237c68f817c to your computer and use it in GitHub Desktop.
Save dai-shi/63a3114c0237c68f817c to your computer and use it in GitHub Desktop.
diff --git a/imports/api/tasks.tests.js b/imports/api/tasks.tests.js
index 1359e85..9b61c5a 100644
--- a/imports/api/tasks.tests.js
+++ b/imports/api/tasks.tests.js
@@ -2,6 +2,7 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
+import { assert } from 'meteor/practicalmeteor:chai';
import { Tasks } from './tasks.js';
@@ -22,6 +23,18 @@ if (Meteor.isServer) {
});
it('can delete owned task', () => {
+ // Find the internal implementation of the task method so we can
+ // test it in isolation
+ const deleteTask = Meteor.server.method_handlers['tasks.remove'];
+
+ // Set up a fake method invocation that looks like what the method expects
+ const invocation = { userId };
+
+ // Run the method with `this` set to the fake invocation
+ deleteTask.apply(invocation, [taskId]);
+
+ // Verify that the method does what we expected
+ assert.equal(Tasks.find().count(), 0);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment