Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow comparison of functions #37

Open
FaisalST32 opened this issue Jan 25, 2022 · 4 comments
Open

Allow comparison of functions #37

FaisalST32 opened this issue Jan 25, 2022 · 4 comments

Comments

@FaisalST32
Copy link

FaisalST32 commented Jan 25, 2022

The test currently fails if a function type is encountered in the nested object. This can become troublesome when we're comparing objects that contain class instances with those instances containing function definitions as well.

Can we add logic to compare functions using strict equality? I could create a PR for this if needed.

@maasencioh
Copy link
Owner

Hello, how will you compare functions? It really feels out of the scope of this project. Maybe if you share an example I could understand more your needs

@FaisalST32
Copy link
Author

Hey, thanks for getting back.
Comparison of functions becomes an issue when dealing with class instances. In the screenshots below, you can see that the test fails when using toBeDeepCloseTo but passes when using toEqual.
image

image

Jest uses strict equality while comparing functions, and I think this library should too.

I have already made the necessary changes, please let me know if you want me to create a PR.

@maasencioh
Copy link
Owner

The problem in a class is that you will compare all the properties or only the numeric ones? As my concern the idea of this package is to extend the toBeCloseTo matcher, that's why I think that if you have a class with 2 properties to be compared to is better to manually compare them.

If you still think that this changes belongs to this repo, you can create a PR and we discuss how to make it work for all of us.

@FaisalST32
Copy link
Author

I have created a PR #38

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

No branches or pull requests

2 participants