Skip to content

Instantly share code, notes, and snippets.

@PilchardFriendly
Created January 28, 2012 04:06
Show Gist options
  • Save PilchardFriendly/1692535 to your computer and use it in GitHub Desktop.
Save PilchardFriendly/1692535 to your computer and use it in GitHub Desktop.
Sample production code using AMD to specify a dependency on jQuery
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!')
});
});
});
//anonymously named 'example-amd-jquery'
define(['jquery'],function($){
return {
message: 'hi!'
}
});
<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