it('should throw an error if the path is empty', function() { var path = './mock-remote/connector'; (function() { Loader.load(path); }).should.throw(); });
describe('#invokeCallback', function () { it('should invoke the function with the parameters', function () { let p1 = 1, p2 = 'str'; let func = function (arg1: number, arg2: string) { p1.should.equal(arg1); p2.should.equal(arg2); }; utils.invokeCallback(func, p1, p2); }); it('should ok if cb is null', function () { let p1 = 1, p2 = 'str'; (function () { utils.invokeCallback(null, p1, p2); }).should.not.throw(); }); });
describe('no-op server events', function() { tests.forEach(function(test) { it(`treat "${test}" as a no-op`, function() { var stopTest = function() { 'Should not call this'.should.not.be.ok(); }; var client = new tmi.client({ logger: { trace: stopTest, debug: stopTest, info: stopTest, warn: stopTest, error: stopTest, fatal: stopTest } }); client._onMessage({data: test}); }); }); });
describe('server crashed, with reconnect: false (default)', function() { before(function() { // Initialize websocket server this.server = new WebSocketServer({port: 7000}); this.client = new tmi.client({ connection: { server: 'localhost', port: 7000 } }); }); it('gracefully handle the error', function(cb) { this.timeout(15000); var client = this.client; var server = this.server; server.on('connection', function(ws) { // Uh-oh, the server dies server.close(); }); client.on('disconnected', function() { 'Test that we reached this point'.should.be.ok(); cb(); }); client.connect().catch(catchConnectError); }); });
describe('#listUserRemoteDir', function () { it('should return sub-direcotry name list of servers/ directory', function () { let expectNames = ['connector', 'area']; let p = pathUtil.listUserRemoteDir(mockBase); should.exist(p); expectNames.length.should.equal(p.length); for (let i = 0, l = expectNames.length; i < l; i++) { p.should.containEql(expectNames[i]); } }); it('should throw err if the servers/ illegal', function () { (function () { pathUtil.listUserRemoteDir('some illegal base'); }).should.throw(); }); });
let n = 3, doneCount = 0; let cdl = CountDownLatch.createCountDownLatch(n, function () { doneCount.should.equal(n); done(); }); CountDownLatch.createCountDownLatch(-1, function () { }); }).should.throw(); }).should.throw(); }); (function () { CountDownLatch.createCountDownLatch(1, null); }).should.throw(); }); }).should.throw(); }); let n = 3; let cdl = CountDownLatch.createCountDownLatch(n, { timeout: 3000 }, function (isTimeout: boolean) { isTimeout.should.equal(true); });
it('should throw exception if the path dose not exist', function() { var path = './some/error/path'; (function() { Loader.loadPath(path); }).should.throw(); });
'Test that we reached this point'.should.be.ok(); cb(); }, client.reconnectTimer);
it('should throw an error if the path is empty', function() { var path = './mock-remote/connector'; (function() { Loader.load(path); }).should.throw(); });
it('should throw exception if the path dose not exist', function() { var path = './some/error/path'; (function() { Loader.loadPath(path); }).should.throw(); });
describe('#listUserRemoteDir', function () { it('should return sub-direcotry name list of servers/ directory', function () { let expectNames = ['connector', 'area']; let p = pathUtil.listUserRemoteDir(mockBase); should.exist(p); expectNames.length.should.equal(p.length); for (let i = 0, l = expectNames.length; i < l; i++) { p.should.containEql(expectNames[i]); } }); it('should throw err if the servers/ illegal', function () { (function () { pathUtil.listUserRemoteDir('some illegal base'); }).should.throw(); }); });
describe('#invokeCallback', function () { it('should invoke the function with the parameters', function () { let p1 = 1, p2 = 'str'; let func = function (arg1: number, arg2: string) { p1.should.equal(arg1); p2.should.equal(arg2); }; utils.invokeCallback(func, p1, p2); }); it('should ok if cb is null', function () { let p1 = 1, p2 = 'str'; (function () { utils.invokeCallback(null, p1, p2); }).should.not.throw(); }); });