Coder Social home page Coder Social logo

Comments (4)

sebastiancarlsson avatar sebastiancarlsson commented on May 27, 2024

PS. If this is confirmed as a bug I'd be happy to give it a stab

from chai-immutable.

astorije avatar astorije commented on May 27, 2024

Hi there,

It's not your case here because you are testing on regular JS objects, and in that case Chai's .deep.equal is used, not Chai Immutable's, but in the Chai Immutable world, the fact that .equal and .deep.equal act similar is normal, which is explained here in the doc. I wanted to point that out just in case.

As far as I can tell, this might be a bug indeed (or at least the outcome doesn't sound right): the value of type is the same, and if the 2 immutable lists have the same value then the assertion should pass.

Did you make sure to run chai.use(chaiImmutable); before? We've seen a similar case here. If not then yes, I'd be happy if you can run some more debugging :)

from chai-immutable.

jopek avatar jopek commented on May 27, 2024

Hi @sebastiancarlsson @astorije,

I also get an error... :

import {List} from 'immutable';
import chai, {expect} from 'chai';
import chaiImmutable from 'chai-immutable';
chai.use(chaiImmutable);

describe('REDUCER', () => {
  it('does things', () => {
    expect(
      List.of({pid: 1}, {pid: 2})
    ).to.equal(
      List.of({pid: 1}, {pid: 2})
    );
  });
});

results in this assertion error:

  REDUCER
     1) does things
  1 failing

  1) REDUCER does things:

      AssertionError: expected 'List [ [object Object], [object Object] ]' to equal 'List [ [object Object], [object Object] ]'
      + expected - actual

from chai-immutable.

astorije avatar astorije commented on May 27, 2024

Hi @jopek,

If you look at my comment above, as well as the documentation on the README and the linked issue, you will see that this is actually the expected behavior:

Immutable data structures should only contain other immutable data structures (unlike Arrays and Objects) to be considered immutable and properly work against .equal(). See this issue for more information.

from chai-immutable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.