Created
January 28, 2012 04:06
-
-
Save PilchardFriendly/1692535 to your computer and use it in GitHub Desktop.
Sample production code using AMD to specify a dependency on jQuery
This file contains 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
define(['factory!example-amd-jquery', 'jquery'], function(exampleDefinition, $){ | |
describe('An Example AMD modules with jquery', function(){ | |
beforeEach(function(){ | |
this.subject = exampleDefinition($); | |
}); | |
it('should say hi', function(){ | |
expect(this.subject).toBe('hi!') | |
}); | |
}); | |
}); |
This file contains 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
//anonymously named 'example-amd-jquery' | |
define(['jquery'],function($){ | |
return { | |
message: 'hi!' | |
} | |
}); |
This file contains 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
<script type='text/javascript' src='lib/jasmine....'></script> | |
<!--add css files, jasmine extensions, etc --> | |
<script type='text/javascript' src='lib/requirejs'></script> | |
<script type='text/javascript'> | |
requirejs.config({ | |
baseUrl: 'Scripts', | |
paths: { | |
'specs': '../specs', | |
'jQuery: 'jquery-1.7.1.js' | |
} | |
}); | |
requirejs.require(['specs/example-amd-spec'], function(){ | |
jasmineEnv.... | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment