Template for Testing with Jasmine
Drop in your code, drop in your Jasmine specs, and away you go! - includes jasmine jquery 2.0.5
by sidouglas
HTML
<script src="http://jasmine.simondouglas.com/jasmine.package.min.js"></script>
CSS
body { overflow-y: scroll; }
.jasmine_html-reporter { background-color: #eeeeee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
.jasmine_html-reporter a { text-decoration: none; }
.jasmine_html-reporter a:hover { text-decoration: underline; }
.jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; }
.jasmine_html-reporter .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
.jasmine_html-reporter .banner { position: relative; }
.jasmine_html-reporter .banner .title { background:...
JavaScript
//--- CODE --------------------------
var foo = 'bar';
//--- SPECS -------------------------
describe("Should", function() {
function sendRequest(callbacks, configuration) {
$.ajax({
url: configuration.url,
dataType: "json",
success: function(data) {
callbacks.checkForInformation(data);
},
error: function(data) {
callbacks.displayErrorMessage();
},
timeout: configuration.remainingCallTime
});
}
it("should make an Ajax request to the correct URL", function() {
var configuration = {
url : "http://www.google.com",
remainingCallTime : 30000
};
spyOn($, "ajax");
sendRequest(undefined, configuration);
expect($.ajax.calls.mostRecent().args[0]["url"]).toEqual(configuration.url);
});
});