Permalink
Browse files

Added a Jasmine test for $.onDemand.use that was missing, for some re…

…ason.
  • Loading branch information...
mmarcon committed Jul 10, 2012
1 parent 3983919 commit b0bb1dbe5ea9f2a4639524b593fd5d9735788875
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/spec/ondemand.spec.js
View
@@ -137,5 +137,24 @@ describe('jQuery OnDemand', function(){
expect(gaaa).toHaveBeenCalledWith('foo', 'bar');
});
+
+ it('Provides a remote object asynchronously on demand', function(){
+ var obj = {
+ rockIt: jasmine.createSpy('rockIt!')
+ };
+ //jQuery getScript mock
+ $.getScript = function(){
+ $.onDemand._proxy.obj = obj;
+ var deferred = $.Deferred();
+ deferred.resolve();
+ return deferred.promise();
+ };
+
+ var promise = $.onDemand.use('obj');
+ promise.done(function(o){
+ o.rockIt();
+ });
+ expect(obj.rockIt).toHaveBeenCalled();
+ });
});

0 comments on commit b0bb1db

Please sign in to comment.