I have a function like below which needs to be test with chai
export class GroupMessage {
public async createTenant(): Promise<void> {
const groupCreator = [];
groupCreator.push(ServiceWrapper.Create(project));
await Promise.all(groupCreator);
}
}
To test this, I have the below test case
it('createTenantshould return create tenant', async () => {
sandbox.stub(ServiceWrapper, 'Create');
const groupNtmMessage = new GroupMessage();
GroupMessage.createTenant();
expect(ServiceWrapper, 'Create').to.have.been.called;
});
With the above code I get the below error
Error: Invalid Chai property: called. Did you mean "all"?
Any way we can test this, I have looked through chai documentation, but haven't found anything
I found the answer to this. Instead of expect, sinon.assert can be used like below
sinon.assert.calledWith(ServiceWrapper.Create, 'test-project');