I have a class which has a private property.
import {Socket} from 'socket.io-client';
export class SocketService {
private socket: Socket;
public initializeSocket() {
if(this.socket) { return; }
this.socket = // get a new Socket
this.socket.on('connect', () => this.processConnect() );
}
private processConnect() {
...
}
}
When write unit test for method initializeSocket()
, how to validate that the on
is called? Any suggestion would be appreciated!