Skip to content

Instantly share code, notes, and snippets.

@tomodutch
Created August 23, 2015 11:09
Show Gist options
  • Save tomodutch/e81dd4b01d9f7f517ae1 to your computer and use it in GitHub Desktop.
Save tomodutch/e81dd4b01d9f7f517ae1 to your computer and use it in GitHub Desktop.
IoC meteor jasmine
function Container() {
this.objects = {};
}
Container.prototype.register = function (name, object) {
return this.objects[name] = object;
};
Container.prototype.get = function (name) {
return this.objects[name];
};
window.container = new Container();
Template.myTemplate.events(container.register('myTemplate.Events', {
'submit form': function(event) {
event.preventDefault();
}
}));
describe('my template form', function() {
it ('should prevent default behaviour on submit', function() {
var event = {preventDefault: function() {}};
spyOn(event, 'preventDefault');
container.get('myTemplate.Events')['submit form'](event);
expect(event.preventDefault).toHaveBeenCalled();
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment