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

Documentation of callIds #2584

Closed
rluvaton opened this issue Feb 5, 2024 · 1 comment
Closed

Documentation of callIds #2584

rluvaton opened this issue Feb 5, 2024 · 1 comment

Comments

@rluvaton
Copy link
Contributor

rluvaton commented Feb 5, 2024

Would you be open for PR to document the callIds property?

The reason it's needed is because let's say I have 2 function fn1 and fn2

And want to test assert the following

fn1();
fn2();
fn1();
fn2();

Currently I can't do that with the current assertions but I want to open it so I can add support for other assertions library to use (my sinon-jest-marchers specifically)

@fatso83
Copy link
Contributor

fatso83 commented Sep 10, 2024

Sorry this was just lying here for forever, but I just never noticed it. You have been able to check exactly this since Sinon 1. This works fine using the SpyCall API:

const assert = require("assert");

const fn1 = sinon.spy();
const fn2 = sinon.spy();

fn1();
fn2();
fn1();
fn2();

const fn1Call0 = fn1.getCall(0);
const fn1Call1 = fn1.getCall(1);
const fn2Call0 = fn2.getCall(0);
const fn2Call1 = fn2.getCall(1);

assert(fn1Call0.calledBefore(fn2Call0));
assert(fn2Call0.calledBefore(fn1Call1));
assert(!fn2Call0.calledBefore(fn1Call0));

As such, I don't think we need to expose the underlying callId? I'll close for now, unless there is something I am missing.

@fatso83 fatso83 closed this as completed Sep 10, 2024
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