fix(ngMock): $httpBackend should match data containing Date objects correctly

If a response or expectation contained a date object then `$httpBackend.expect`
was not matching correctly.

This commit encodes then decodes the object being matched to ensure consistency.

Closes #5127
This commit is contained in:
Bastien Caudan
2013-11-25 18:00:21 +01:00
committed by Peter Bacon Darwin
parent a7f886e6c8
commit 1025f6ebf4
2 changed files with 9 additions and 1 deletions

View File

@@ -929,6 +929,12 @@ describe('$http', function() {
});
it('should transform object with date into json', function() {
$httpBackend.expect('POST', '/url', {"date": new Date(Date.UTC(2013, 11, 25))}).respond('');
$http({method: 'POST', url: '/url', data: {date: new Date(Date.UTC(2013, 11, 25))}});
});
it('should ignore strings', function() {
$httpBackend.expect('POST', '/url', 'string-data').respond('');
$http({method: 'POST', url: '/url', data: 'string-data'});