Added test (#1517)

Added test for removal of map key in this.methods in HubConnection
This commit is contained in:
Olof Dahlbom 2018-03-01 18:34:29 +01:00 committed by David Fowler
parent 569c31bc62
commit af9974178b
1 changed files with 27 additions and 0 deletions

View File

@ -150,6 +150,33 @@ describe("HubConnection", () => {
expect(warnings).toEqual(["No client method with the name 'message' found."]);
});
it("invocations ignored in callbacks that have registered then unregistered", async () => {
const warnings: string[] = [];
const logger = {
log: (logLevel: LogLevel, message: string) => {
if (logLevel === LogLevel.Warning) {
warnings.push(message);
}
},
} as ILogger;
const connection = new TestConnection();
const hubConnection = new HubConnection(connection, { logger });
const handler = () => { };
hubConnection.on('message', handler);
hubConnection.off('message', handler);
connection.receive({
arguments: ["test"],
invocationId: 0,
nonblocking: true,
target: "message",
type: MessageType.Invocation,
});
expect(warnings).toEqual(["No client method with the name 'message' found."]);
});
it("callback invoked when servers invokes a method on the client", async () => {
const connection = new TestConnection();