What are the shortcomings of javascript's revealing module pattern when unit testing with Jasmine? -
what shortcomings of javascript's revealing module pattern when unit testing jasmine?
and potential workarounds?
i'm using requirejs, special kind of module pattern, on year , cant see shortcomings. module should use dependency injection can replace dependencies of module mocks in test.
var mymodule = (function(dep1){ function somefancyalgorythm(a){return +1} return { foo: function(a){ dep1(somefancyalgorythm(a)) } } })(dep1)
in test
describe('mymodule',function(){ var dep1; var module; beforeeach(function(){ dep1 = jasmine.createspy(); module = mymodule(dep1) }) it('make crazy stuff', function(){ module.foo(1); expect(dep1).tohavebeencalledwith(2); }) })
Comments
Post a Comment