From 5b0d0683584e304db30462f3448d9f090120c444 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Sat, 25 Feb 2012 18:49:54 -0800 Subject: fix($http): Do not serialize File object --- test/service/httpSpec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/service/httpSpec.js b/test/service/httpSpec.js index ad376b5f..4c8471d8 100644 --- a/test/service/httpSpec.js +++ b/test/service/httpSpec.js @@ -564,6 +564,25 @@ describe('$http', function() { $httpBackend.expect('POST', '/url', 'string-data').respond(''); $http({method: 'POST', url: '/url', data: 'string-data'}); }); + + + it('should ignore File objects', function() { + var file = { + some: true, + // $httpBackend compares toJson values by default, + // we need to be sure it's not serialized into json string + test: function(actualValue) { + return this === actualValue; + } + }; + + // I'm really sorry for doing this :-D + // Unfortunatelly I don't know how to trick toString.apply(obj) comparison + spyOn(window, 'isFile').andReturn(true); + + $httpBackend.expect('POST', '/some', file).respond(''); + $http({method: 'POST', url: '/some', data: file}); + }); }); -- cgit v1.2.3