本文整理匯總了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();
});