Comments (8)
Gotcha, thanks for the clarification!
Agreed, let's go with to.referenceEqual
, at least while in v2, and if it needs changing in the future, it could be done in v3. But in the meantime and if possible, I'd rather keep .to.equal
as a value equality check since it's more in the spirit of Immutable.js.
Thank you both for your help, looking forward to a PR! :)
from chai-immutable.
Sure -> #218 😉
from chai-immutable.
Hey @jakubzitny! Thanks for your feedback 🙏
I am totally open to a PR (I promise I will review it faster than I replied to your issue 😅). I prefer the option that maintains parity with the core of chai
as this is pretty much what this plugin tries to achieve.
Wanna help? :)
from chai-immutable.
Actually, thinking more about this, I think .to.equal
should stay the way it is because that's more in line with what Immutable.js is.
I think comparing references is an edge case in the world of Immutable.js (may I ask you for a use case?) so it would be unfortunate to tie it to the default meaning of .to.equal
I think.
At the end of the day, assuming a
and b
are Immutable.js object, it shouldn't matter if expect(a).to.equal(b)
ensures the references are the same, it's all value-based. Maybe not being able to assert reference equality is a sign that something might be fishy in the specs, but if there needs to be an escape hatch, then an explicit .to. referenceEqual
is probably more appropriate. I'd be curious about use case before having a definitive opinion however.
from chai-immutable.
Our use case is covering shallow compare compatibility of our state. We have a store which returns a Map
for instance and we want to ensure that it returns the same map instance on multiple invocations unless there were changes between getter calls. This allows us to optimize React component rerendering as the default comparison logic relies on reference equality.
from chai-immutable.
Thanks for the answers. Well, the use case is simple — I wanna be sure that a method (from flux store, a custom collection, or any class that stores Immutable data internally and returns them filtered/modified/mapped) returns always the same "modified" collection and does not re-create it on call every time (unless the data has changed).
Or as @jankuca mentioned above.
I think changing the .to.equal
behaviour would be more "correct", but in order to cover most cases with Immutable.js and also to keep the backward compatibility, I would really be better to just implement to.referenceEqual
.
from chai-immutable.
Hey @jakubzitny and @jankuca, quick follow-up: do you still intend to open a PR for this? I'd be happy to include it in the next release :)
from chai-immutable.
This has now be released as part of v2.1.0. Thanks again!
from chai-immutable.
Related Issues (20)
- Add support for custom messages HOT 1
- [email protected]" has incorrect peer dependency "immutable@^3.0.0". HOT 4
- latest immutablejs support(Is this library even alive?) HOT 5
- Dependency Dashboard
- Publish new version! HOT 3
- Replace JSCS with ESLint
- Use ES6 in the documentation HOT 1
- `not` in assertions is ignored HOT 4
- Publish version HOT 3
- App crash if receive an REMOTE_WIDGET_DRAGGING or UPDATE_WIDGET before mural is fully loaded HOT 2
- Add `.deep.include` for deep equality comparisons
- Add support for deep flag for the keys assertion
- Drop support of Node v0.10 and v0.12
- Support Chai v4's `.deep.property`
- Write comprehensive tests for `.not.property` HOT 2
- Feature request: comparison of Maps via include HOT 3
- npm WARN [email protected] requires a peer of chai@>= 2.0.0 < 4 but none was installed. HOT 9
- Investigate potential remaining items for Chai v4 support HOT 8
- Cannot find module 'immutable' HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chai-immutable.