-
Notifications
You must be signed in to change notification settings - Fork 27.4k
1.2.5 angular-mocks copy change breaks tests using XML datatype #5429
Comments
One solution would be to make angular.copy support recursive data structures. I made this change locally, but it is not enough. If you just take this approach to copying an XMLDocument, you will be left with just the properties of the document, none of the methods that exist on the object's prototype. And then when someone tries to use one of those prototype methods, your test blows up. So... we could add a special case for XMLDocument in copy and use cloneNode. } else if (source.cloneNode) {
destination = source.cloneNode();
} But is that too specific to one type? Ideally users would be able to extend this copy method to support any type out there. |
Here are my fixes I described above: |
A workaround for this is to not use responseType at all in $http and manually parse the response as XML. For a lot of code this is probably the correct thing to do anyway as you should look at the response's ContentType to determine how to parse. For example, you may think the response is XML, but a 500 error might return plaintext and your code will blow up. |
|
Oh but I just realised that there are two issues here. The cyclic one is fixed. The XML one is not. |
Apparently the XML datatype in Chrome/Firefox (and others?) contains pointers to itself. The change here (f69dc16) copies the HTTP response.
If you are mocking an HTTP service with XML datatype as the return type, copy() never terminates.
The text was updated successfully, but these errors were encountered: