Created
August 23, 2015 11:09
-
-
Save tomodutch/e81dd4b01d9f7f517ae1 to your computer and use it in GitHub Desktop.
IoC meteor jasmine
This file contains hidden or 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
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(); |
This file contains hidden or 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
Template.myTemplate.events(container.register('myTemplate.Events', { | |
'submit form': function(event) { | |
event.preventDefault(); | |
} | |
})); |
This file contains hidden or 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
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