UNPKG

emailjs-tcp-socket

Version:

This shim brings the W3C Raw Socket API to node.js and Chromium. Its purpose is to enable apps to use the same api in Firefox OS, Chrome OS, and on the server.

53 lines (41 loc) 1.24 kB
/* eslint-disable no-unused-expressions */ import TCPSocket from './node-socket' describe('TCPSocket Node.js socket unit tests', function () { var socket, nodeSocketStub beforeEach(function () { socket = TCPSocket.open('127.0.0.1', 9000, { useSecureTransport: false }) expect(socket).to.exist expect(socket._socket).to.exist var Socket = function () { } Socket.prototype.on = function () { } Socket.prototype.write = function () { } Socket.prototype.end = function () { } socket._socket = nodeSocketStub = sinon.createStubInstance(Socket) }) describe('open', function () { it('should not explode', function () { socket = TCPSocket.open('127.0.0.1', 9000, { useSecureTransport: false }) expect(socket).to.exist }) }) describe('close', function () { it('should not explode', function () { nodeSocketStub.end.returns() socket.close() expect(socket.readyState).to.equal('closing') }) }) describe('send', function () { it('should not explode', function (done) { nodeSocketStub.write.yields() socket.ondrain = function () { done() } socket.send(new ArrayBuffer()) }) }) })