Git Product home page Git Product logo

Comments (8)

stalniy avatar stalniy commented on May 27, 2024 1

1.0.0 released! Hooray!

from chai-spies.

cdgn-coding avatar cdgn-coding commented on May 27, 2024

This seems to be an expected behavior of the actual algorithm that checks the call argument. If this is true, I can add the fix to my fork and send the pull request if, of course, other contributors agree.

I'll soon take a look again to the algorithm and come back to you.


After taking a look again to the algorithm and the tests, this should actually work.

  Chai Spies
    .with(arg, ...)
      √ checks spy calls with repeating params (89ms)

There may be another factor acting within this issue.

from chai-spies.

stalniy avatar stalniy commented on May 27, 2024

You need to use with.exactly which will check order of args.

Please close issue if that works for you

from chai-spies.

apricoder avatar apricoder commented on May 27, 2024

Thanks, using .with.exactly(1, 1) worked here, though I consider it a workaround rather than a solution of issue.

I still can't understand why .with assertion can't handle repeating params:

it('checks spy calls with unique params', () => {
    const object = {};
    const fooFunction = chai.spy.on(object, 'foo');
    object.foo(1, 2, 3);
    chai.expect(fooFunction).to.have.been.called.with(2);
  });

  it('checks spy calls with repeating params', () => {
    const object = {};
    const fooFunction = chai.spy.on(object, 'foo');
    object.foo(1, 2, 2);
    chai.expect(fooFunction).to.have.been.called.with(2);
  });

Second test fails while first one passes which isn't the obvious behavior IMHO. Yes I could use .with.exactly and check order of all three args, but I think the order isn't significant if I just want to check if number 2 appeared among function args.

from chai-spies.

keithamus avatar keithamus commented on May 27, 2024

@olebokolo I would expect the tests in your original comment to pass. You say you have a patch? Please do send this over! with should handle repeating params.

from chai-spies.

stalniy avatar stalniy commented on May 27, 2024

I guess similar fix was added in e13621b

from chai-spies.

keithamus avatar keithamus commented on May 27, 2024

Yup! Looks like it. Let's cut a release now and @olebokolo can try and reproduce with chai spies 1.0.0

from chai-spies.

apricoder avatar apricoder commented on May 27, 2024

Works as expected with 1.0.0 👍
Thanks everybody

from chai-spies.

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.