Created
August 8, 2011 01:26
-
-
Save jessemiller/1131041 to your computer and use it in GitHub Desktop.
Second step of test-driven javascript
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
<!-- Testing pairs --> | |
<script type="text/javascript" src="banana-populator.js"></script> | |
<script type="text/javascript" src="../public/javascripts/banana-populator.js"></script> |
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
module("Banana Populator"); | |
test("On instantiation, populator should do a get request to /bananas", function() { | |
expect(2); | |
var fakeAjax = function( params ) { | |
equal( params.url, '/bananas', 'Populator should be requesting from /bananas' ); | |
equal( params.type, 'get', 'Populator should be doing a get request' ); | |
} | |
var populator = new tdd.BananaPopulator({ | |
ajax: fakeAjax | |
}); | |
}); |
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
// Setup a namespace to use for all our classes, we just do this to avoid conflicts with other libraries | |
if (typeof tdd === "undefined") { | |
tdd = {}; | |
} | |
tdd.BananaPopulator = Class.extend({ | |
defaults: { | |
ajax: $.ajax | |
}, | |
init: function( params ) { | |
$.extend( this, this.defaults, params); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment