Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('streams event logs to a socket', function() {
this.timeout(100000);
const MockWebSocket = require('mock-socket').WebSocket;
const MockServer = require('mock-socket').Server;
var server = new MockServer('ws://localhost:40002');
var socket = new MockWebSocket('ws://localhost:40002');
socket.connected = true;
var lineBuffer = require('../../lib/linebuffer');
lineBuffer.setSocket(socket);
var windowsUtilities = requireUncached('../../lib/windows-utilities');
return new Promise((resolve) => {
server.on('message', data => {
debug('received message!');
debug(data);
var message = JSON.parse(data);
var line = message.ls[0].l;
assert.equal(JSON.parse(line).Message, 'arbitraryData');
resolve(true);
});
setInterval(() => {
commit: () => {},
dispatch: () => {}
})
mockStore.expects('dispatch').withArgs(expectedMsg.namespace + '/' + expectedMsg.action, expectedMsg)
mockServer = new Server(wsUrl)
mockServer.on('connection', ws => {
ws.send(JSON.stringify(expectedMsg))
})
Vue.use(VueNativeSock, wsUrl)
let vm = new Vue()
observer = new Observer(wsUrl, {
store: mockStore.object,
format: 'json',
websocket: new WebSocket(wsUrl)
})
setTimeout(() => {
mockStore.verify()
mockServer.stop(done)
}, 100)
})
beforeEach(() => {
mockServer = new Server(wsUrl)
mockServer.on('connection', ws => ws.send('hi'))
Vue.use(VueNativeSock, wsUrl)
vm = new Vue()
mockStore = sinon.mock({ commit: () => {} })
observer = new Observer(wsUrl, {
store: mockStore.object,
reconnection: true,
reconnectionAttempts: 2,
WebSocket: new WebSocket(wsUrl),
})
})
function mockEngine() {
var stamp = Date.now();
var url = `ws://127.0.0.1:4848/${stamp}`;
const server = new Server(url);
const ws = new WebSocket(url);
server.on("message", msg => {
const { id, method } = JSON.parse(msg);
server.send(
JSON.stringify({
jsonrpc: "2.0",
id: id,
result: {
foo: "bar",
method
}
})
);
});
beforeEach(() => {
server = new Server("ws://localhost:8000")
socket = new WebSocket("ws://localhost:8000")
transport = new WebSocketTransport(socket)
subscriber = jest.fn()
})