Created
January 29, 2015 14:25
-
-
Save exegeteio/6fde26eae3bbbbff0e26 to your computer and use it in GitHub Desktop.
Testing Meteor Methods with TinyTest and describe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Quiz | |
constructor: (@quizCollection) -> | |
create: (description, options) -> | |
check description, String | |
check options, Array | |
if options.length is 0 | |
throw new Meteor.Error('Must specify options.') | |
@quizCollection.insert { | |
description: description, | |
options: options, | |
voters: [], | |
total_responses = 0 | |
} | |
quizCollection = new Meteor.Collection 'test_quiz' | |
quizzer = new Quiz quizCollection | |
if Meteor.isServer | |
Meteor.methods { | |
'createQuiz': (description, options) -> | |
quizzer.create description, options | |
} | |
Meteor.publish 'quizCollection', -> | |
quizCollection.find {} | |
if Meteor.isClient | |
Meteor.subscribe 'quizCollection' | |
describe 'exegete46:quiz', -> | |
context '#create', -> | |
it "won't allow no options", (test, next) -> | |
Meteor.call 'createQuiz', quiz_description, [], (err, val) -> | |
test.throws -> | |
if err | |
throw new Meteor.Error err | |
if not err | |
throw new Meteor.Error "Error wasn't thrown!" | |
next() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment