Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngMock): httpBackend match data with dates (1.2.2 regression) #5127

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,8 @@ function MockHttpExpectation(method, url, data, headers) {
if (angular.isUndefined(data)) return true;
if (data && angular.isFunction(data.test)) return data.test(d);
if (data && angular.isFunction(data)) return data(d);
if (data && !angular.isString(data)) return angular.equals(data, angular.fromJson(d));
if (data && !angular.isString(data))
return angular.equals(angular.fromJson(angular.toJson(data)), angular.fromJson(d));
return data == d;
};

Expand Down
6 changes: 6 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,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'});
Expand Down