javascript - Accessing a Meteor Template Helper Function in Jasmine for Integration Testing -



javascript - Accessing a Meteor Template Helper Function in Jasmine for Integration Testing -

i'm trying run jasmine client integration tests on meteor project. i'm using meteor 0.9.4, , sanjo:jasmine bundle jasmine.

i have written test looks like:

describe("template.dashboard.tasks", function() { it("ela displays right assessment", function() { session.set("selected_subject", "math"); session.set('selected_grade', "1"); tasks = template.dashboard.tasks(); expect(true).tobe(true); }); });

i error before can end of test:

cannot read property 'tasks' of undefined

this means template.dashboard not exist within scope of test.

template.dashboard.tasks() helper function works completely, , in js file within view folder. regular jasmine tests work expected, seek utilize 1 of own functions file, doesn't work.

my question is: there need give jasmine test access template helper functions?

in meteor, template helper functions used formatted this:

template.dashboard.tasks = function () { ... };

but has been deprecated, , new format is:

template.dashboard.helpers({ tasks: function(){ ... } });

in jasmine, previous formatting, access helper functions like:

template.dashboard.tasks();

but must phone call helper functions this:

template.dashboard.__helpers[' tasks']();

sanjo (owner of meteor-jasmine repo) suggested using function create easier phone call helper functions (especially if syntax ends getting changed again):

function callhelper(template, helpername, context, args) { context = context || {}; args = args || []; template.__helpers[' ' + helpername].apply(context, args); }

javascript unit-testing templates meteor jasmine

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -