Skip to content

Commit

Permalink
[fixed] let jqXHR object survive the fixture copy
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Jun 12, 2014
1 parent cc6008e commit 46440df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export var __fixtures__ = {};
*/

export function defineFixture(url, fixture) {
__fixtures__[url] = JSON.parse(JSON.stringify(fixture));
if (fixture.response) {
fixture.response = JSON.parse(JSON.stringify(fixture.response));
}
__fixtures__[url] = fixture;
}

/*
Expand Down
15 changes: 15 additions & 0 deletions test/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ asyncTest('the fixture is unaffected by external change', function() {
)
});

asyncTest('the fixture jqXHR survives the response copy', function() {

ic.ajax.defineFixture('/foo', {
response: {foo: 'bar'},
textStatus: 'success',
jqXHR: { getResponseHeader: function(a) { return a; } }
});

ic.ajax.raw('/foo').then(function(result) {
start();
equal(result.jqXHR.getResponseHeader('foo'), 'foo');
}
)
});

test('throws if success or error callbacks are used', function() {
var k = function() {};
throws(function() {
Expand Down

0 comments on commit 46440df

Please sign in to comment.