Skip to content

Instantly share code, notes, and snippets.

@dai-shi
Created March 28, 2016 09:40
Show Gist options
  • 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.

Revisions

  1. dai-shi created this gist Mar 28, 2016.
    31 changes: 31 additions & 0 deletions simple-todos-react-11.4.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    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);
    });
    });
    });