Open lionelB opened 8 years ago
after digging inside the mock library, I found that update that the problem come from here
- if (pending.message === msg.message) {
+ if (pending === msg) {
and this a my working / failin test case
describe('publish', function() {
var socket;
beforeEach(function(){
$websocketBackend.expectConnect('ws://websocket.url:443');
$websocketBackend.expectSend( JSON.stringify({msg:'yolo'}) );
socket = $websocket('ws://websocket.url:443');
// Fake socket connection open
socket.socket.readyState = 1;
})
it('should publish data', function(){
socket.send( JSON.stringify({msg:'yolo'}) );
$websocketBackend.flush();
})
});
Hope it helps I will try to submit a PR for the mock library
Hello,
I'm trying to use the
ngWebSocketMock
mock for test but it seems thatexpectSend
doesn't work well.expectConnect
works fine once I added the afterEach verifyOutstandingBut I can't figure how use
expectSend()
I fix an error here since _onMessageHandler is called with a
MessageEvent
Can you provide a working (passing/failing) test case example ?