You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it('mock called with another mock', async () => {
class Cheese {
constructor(public name: string) {}
}
class Potato {
private cheese: Cheese;
public applyCheese(cheese: Cheese) {
this.cheese = cheese;
}
}
const mockPotato = createMock<Potato>();
const mockCheese = createMock<Cheese>();
mockPotato.applyCheese(mockCheese);
expect(mockPotato.applyCheese).toHaveBeenCalledTimes(1);
// These all pass, but they should fail because applyCheese wasn't called with these values
expect(mockPotato.applyCheese).toHaveBeenCalledWith('kaboom');
expect(mockPotato.applyCheese).toHaveBeenCalledWith(42);
expect(mockPotato.applyCheese).toHaveBeenCalledWith(null);
// This one should pass (and does)
expect(mockPotato.applyCheese).toHaveBeenCalledWith(mockCheese);
});
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: