Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Created January 12, 2014 14:34
Show Gist options
  • Save dbouwman/8385293 to your computer and use it in GitHub Desktop.
Save dbouwman/8385293 to your computer and use it in GitHub Desktop.
Using a mock to test the full fetch method, without a server
describe('loads itself from the service', function () {
beforeEach(function() {
json = getJSONFixture('entities/Dataset/dataset.json');
var response = {
status: 200,
responseText: JSON.stringify(json)
};
jasmine.Ajax.useMock();
model = new Composer.Models.Dataset({id:json.data.id});
model.fetch();
var request = mostRecentAjaxRequest();
request.response(response);
});
it('sets the version', function() {
expect(model.get('current_version')).toEqual(json.data.current_version);
});
//lots more tests removed for brevity
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment