本文整理汇总了TypeScript中Sinon.SinonMock类的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonMock类的具体用法?TypeScript SinonMock怎么用?TypeScript SinonMock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SinonMock类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("Coordinates users joining games/rooms via socket communication.", () => {
mockedClients.expects("bySocket").once().withExactArgs(testSocket).returns(client);
mockedRooms.expects("get").once().withExactArgs(room).returns(room);
mockedClient.expects("joinRoom").once().withExactArgs(room);
mockedClient.expects("emit").once().withExactArgs("joinedGame", testGame);
mockedClient.expects("broadcast").twice();
roomsListener.join(room, testSocket);
});
示例2: request
it("Saves a user to the database.", () => {
mockBackend.expects("saveUser").once().withExactArgs(user).resolves(user);
mockClients.expects("updateUser").once().withExactArgs(user, user.id);
return request(createUrlCall(post, `/users/save`, user)).then((response: User) => {
expect(response).to.deep.equal(user);
mockBackend.verify();
mockClients.verify();
});
});
示例3: it
it("Triggers a socket emit when calling a transmitter.", () => {
const value: string = "OkOkOkOK";
actions.forEach((transmitter: string): any => {
mockedSocket.expects("emit").withExactArgs(transmitter, value);
transmitters[transmitter](value);
});
mockedSocket.verify();
mockedSocket.restore();
});