github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/sockjs-client-1.1.0/tests/lib/main-node.js (about) 1 'use strict'; 2 3 var expect = require('expect.js') 4 , proxyquire = require('proxyquire') 5 ; 6 7 describe('SockJS', function() { 8 describe('Constructor', function () { 9 10 describe('WebSocket specification step #2', function () { 11 var main = proxyquire('../../lib/main', { './location': { 12 protocol: 'https' 13 }}); 14 var sjs = proxyquire('../../lib/entry', { './main': main }); 15 16 it('should throw SecurityError for an insecure url from a secure page', function () { 17 expect(function () { 18 sjs('http://localhost'); 19 }).to.throwException(function (e) { 20 expect(e).to.be.a(Error); 21 expect(e.message).to.contain('SecurityError'); 22 }); 23 }); 24 25 it('should throw SyntaxError for an invalid url', function () { 26 expect(function () { 27 sjs('//localhost'); 28 }).to.throwException(function (e) { 29 expect(e).to.be.a(SyntaxError); 30 }); 31 }); 32 33 it('should throw SyntaxError for an empty url - #8', function () { 34 expect(function () { 35 sjs(''); 36 }).to.throwException(function (e) { 37 expect(e).to.be.a(SyntaxError); 38 }); 39 }); 40 }); 41 42 }); 43 });