// This works correctly in Sinon 14: `npm i sinon@14`
// Breaks in 15.0.1 and 15.0.2: `npm i sinon@15.0.1` or `npm i sinon@15.0.2` breaks
require('@fatso83/mini-mocha').install();
const sinon = require("sinon");
class TestService {
doSomething(value) {
return `TestService:doSomething:${value}`;
}
doSomethingElse(value) {
return `TestService:doSomethingElse:${value}`;
}
}
describe("sinon breaking change", () => {
it("should call through", async () => {
const stubTestService = sinon.createStubInstance(TestService);
stubTestService.doSomething.callThrough();
console.log("val1: ", stubTestService.doSomething("hei"));
console.log("val2: ", stubTestService.doSomethingElse("hei"));
expect(stubTestService.doSomething("test1")).toEqual(
"TestService:doSomething:test1"
);
expect(stubTestService.doSomethingElse("test2")).toEqual(undefined);
});
});