meteor - How can I change a laika test from testing successful insert to testing for failed insert? -
i've updated allow , deny rules client. no inserts, updates or removes should work on client side. test (listed below) passed because tested see if client insert collection. want switch test make sure test passes when client can't insert collection.
how done?
//tests/tests.js var assert = require('assert'); suite('donate', function() { test('in server', function(done, server) { server.eval(function() { donate.insert({fname: 'george'}); var docs = donate.find().fetch(); emit('docs', docs); }); server.once('docs', function(docs) { assert.equal(docs.length, 1); done(); }); }); }); test('using both client , server', function(done, server, client) { server.eval(function() { donate.find().observe({ added: addednewdonate }); function addednewdonate(donate) { emit('donate', donate); } }).once('donate', function(donate) { assert.equal(donate.fname, 'george'); done(); }); client.eval(function() { donate.insert({fname: 'george'}); }); });
you might going in wrong way. testing see if insert denied expected testing meteor core tested. put way, should testing method returns false insert deny property. if doing is:
donate.deny({ insert: function(){ return false; } )}; then don't need test since meteor core tested enough know work.
on other hand if have
function complexdenyfunction(){ //perform complex actions //if complex conditions satisfied //return true //else return false return result; } donate.deny({ insert: complexdenyfunction }); then want create scenarios complexdenyfunction return true , false , test complexdenyfunction see if if returns expected results
Comments
Post a Comment