From a517a239823bfcbf0a22f4a779aee025d478c88a Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Sun, 12 Apr 2015 15:53:21 -0600 Subject: [PATCH] Adding test for parsing JSON response --- test/specs/transform.spec.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/specs/transform.spec.js b/test/specs/transform.spec.js index e04607d..806a542 100644 --- a/test/specs/transform.spec.js +++ b/test/specs/transform.spec.js @@ -29,6 +29,31 @@ describe('transform', function () { }, 0); }); + it('should transform string to JSON', function (done) { + var request, response; + + axios({ + url: '/foo' + }).then(function (data) { + response = data; + }); + + setTimeout(function () { + request = jasmine.Ajax.requests.mostRecent(); + + request.respondWith({ + status: 200, + responseText: '{"foo": "bar"}' + }); + + setTimeout(function () { + expect(typeof response.data).toEqual('object'); + expect(response.data.foo).toEqual('bar'); + done(); + }, 0); + }, 0); + }); + it('should override default transform', function (done) { var request; var data = {