I am trying to test a event in a Template. Within the click event, there is a Reactive Var that gets set.
The test is blocked by the Reactive Var.
Any ideas on how I stub or mock a reactive var in a template?I tried adding it to the template (template.reactiveVar = “whatever”), but no go, as I don’t think it’s writeable.
The ?? indicate where I am wondering what to put.
it(‘sets a reactive var when a button is clicked’, function(){
Template.button.fireEvent('click ', {
context: { some: 'values', 'currentlySelectedEnvironment': 'sup' },
event: {'target': {'text': 'testEnvironment', 'files': [{'type': type, 'name': name}]} },
templateInstance:new Template('upload', function(e) {
this.currentlySelectedEnvironment = new ReactiveVar(false)
})
});
Template.button.fireEvent('click button', {'event': {'target': {'text': 'dataFromClick', Template.button);
chai.assert.equal(Template.reactiveVar, "clicked")
};
Template.button.events{(
‘click button’: function(evt, template){
var text = evt.target.text
template.reactiveVar.set(text)
}
})
TypeError: Cannot read property ‘set’ of undefined
Any ideas?