Initial commit - cloned the Svelte todo's app with google login enabled as a starting point. This system will initially be used to let the chrome extension for students report which computers are used by which students and when.
This commit is contained in:
41
imports/api/tasks.tests.js
Normal file
41
imports/api/tasks.tests.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/* eslint-env mocha */
|
||||
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Random } from 'meteor/random';
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { Tasks } from './tasks.js';
|
||||
|
||||
if (Meteor.isServer) {
|
||||
describe('Tasks', () => {
|
||||
describe('methods', () => {
|
||||
const userId = Random.id();
|
||||
let taskId;
|
||||
|
||||
beforeEach(() => {
|
||||
Tasks.remove({});
|
||||
taskId = Tasks.insert({
|
||||
text: 'test task',
|
||||
createdAt: new Date(),
|
||||
owner: userId,
|
||||
username: 'tmeasday',
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user