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

angular-mocks matchData fails with dates #6126

Closed
m3kka opened this issue Feb 5, 2014 · 1 comment
Closed

angular-mocks matchData fails with dates #6126

m3kka opened this issue Feb 5, 2014 · 1 comment

Comments

@m3kka
Copy link

m3kka commented Feb 5, 2014

#5127 seems not solved in 1.2.11

Updated the plunkr of the previous submitter for the new version of Angular

I've traced the problem down to (angular-mocks)

  this.matchData = function(d) {
    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)); // <--- this
    return data == d;
  };

Basically the object saved inside the expectations property of $httpBackend retain the normal date type

{ DateProperty : Wed Feb 05 2014 11:57:59 GMT+0000 (GMT Standard Time) }

while, as expected, JSON.parse() contained in the angular.fromJson() function produces:

{ DateProperty : "2014-02-05T11:57:59.000Z" }

considering this results angular.equals() fails and matchData() also fails accordingly

@pkozlowski-opensource
Copy link
Member

This seems to be fixed in 1.2.27: http://plnkr.co/edit/gzg2D1ThUpwe8BONwZms?p=preview

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants