Created
November 12, 2011 01:31
-
-
Save superchris/1359867 to your computer and use it in GitHub Desktop.
loading templates in jasmine specs
This file contains hidden or 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
jasmine.Fixtures.prototype.loadTemplate_ = function(template) { | |
var templateUrl = "/backbone/templates/" + template; | |
var self = this; | |
$.ajax({ | |
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded | |
cache: false, | |
dataType: 'html', | |
url: templateUrl, | |
success: function(data) { | |
$('#' + self.containerId).append(data); | |
} | |
}); | |
}; | |
function loadTemplate(template) { | |
jasmine.getFixtures().loadTemplate_(template); | |
} | |
jasmine.Fixtures.prototype.loadJson_ = function(jsonFile) { | |
var jsonUrl = "/spec/javascripts/fixtures/" + jsonFile; | |
var json = ""; | |
var self = this; | |
$.ajax({ | |
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded | |
cache: false, | |
dataType: 'json', | |
url: jsonUrl, | |
success: function(data) { | |
json = data; | |
} | |
}); | |
return json; | |
}; | |
function loadJson(jsonFile) { | |
return jasmine.getFixtures().loadJson_(jsonFile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment