jam-cloud/spec/javascripts/helpers/testutil.js

29 lines
958 B
JavaScript

(function(context, $) {
context.JKTestUtils = {
loadFixtures: function(path) {
//path = 'file:///home/jonathon/dev/jamkazam/jam-web' + path;
//path = 'http://localhost:9876' + path;
var needTestFixtures = ($('#test-fixtures').length === 0);
if (needTestFixtures) {
$('body').append('<div id="test-fixtures"></div>');
}
$.ajax({
url:path,
async: false,
success: function(r) {
$('#test-fixtures').append(r);
},
error: function(jqXHR, textStatus, errorThrown) {
// Assumes we're in a jasmine context
throw 'loadFixtures error: ' + path + ': ' + errorThrown;
}
});
},
removeFixtures: function() {
$('#test-fixtures').remove();
}
};
})(window, jQuery);