How to use createConnection method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

app.js

Source:app.js Github

copy

Full Screen

2var app = express();3//链接数据库模块4var mysql = require("mysql");5//连接服务器配置.......................................................................6function createConnection() {7 var connection = mysql.createConnection({8 host: 'localhost',// 127.0.0.19 user: 'root',10 password: '',11 database: 'homestay'12 });13 return connection14}15//解决跨域16app.all('*', function(req, res, next) {17 res.header("Access-Control-Allow-Origin", "*");18 res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");19 res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");20 res.header("X-Powered-By",' 3.2.1')21 next();22});23app.use(express.static('public'));24// parse application/json 25//get请求.................................................................................26//更新民宿信息的接口27app.get('/edithhomestay', function(req, res) {28 //然后请求的很快的时候才能正常关闭链接、29 var connection = createConnection();30 connection.connect();31 //引入查找模块32 require('./router/update').edithhomestay(req,res,connection);33 console.log(req.query)34})35//.......................赖俊豪写的两个接口...........................................36app.get('/userlogin',function(req,res){37 // res.append("Access-Control-Allow-Origin", "*");38 var connection = createConnection();39 connection.connect();40 require('./router/userlogin.js').userlogin(req,res,connection);41})42//.......................赖俊豪写的两个接口................................................43//通过aid寻找管理员的信息44app.get('/selectaid', function(req, res) {45 46 var connection = createConnection();47 connection.connect();48 //引入查找模块49 require('./router/select').selectAid(req,res,connection);50 console.log(req.query)51}) 52//订单插入53app.get('/insertord', function(req, res) {54 55 var connection = createConnection();56 connection.connect();57 //引入插入模块 58 require('./router/insert').inserthzj(req,res,connection)59 console.log(req.query)60})61//工作计划制定62app.get('/setplan', function(req, res) {63 64 var connection = createConnection();65 connection.connect();66 //引入插入模块 67 require('./router/insert').setPlan(req,res,connection)68 console.log(req.query)69})70//删除工作计划71app.get('/closeplan', function(req, res) {72 73 var connection = createConnection();74 connection.connect();75 //引入查找模块76 require('./router/del').closePlan(req,res,connection);77 console.log(req.query)78})79//解雇员工80app.get('/dismissal', function(req, res) {81 82 var connection = createConnection();83 connection.connect();84 //引入查找模块85 require('./router/del').disMissal(req,res,connection);86 console.log(req.query)87})88//删除homestary里面的民宿信息89app.get('/delethomestray', function(req, res) {90 91 var connection = createConnection();92 connection.connect();93 //引入查找模块94 require('./router/del').delSelf(req,res,connection);95 console.log(req.query)96}) 97//删除checkhomestay里面的民宿信息98app.get('/deletcheck', function(req, res) {99 100 var connection = createConnection();101 connection.connect();102 //引入查找模块103 require('./router/del').delCheck(req,res,connection);104 console.log(req.query)105}) 106//增加审核过关的民宿信息107app.get('/insertcheck', function(req, res) {108 109 var connection = createConnection();110 connection.connect();111 //引入插入模块 112 require('./router/insert').insertCheck(req,res,connection)113 console.log(req.query)114})115//增加116app.get('/insert', function(req, res) {117 118 var connection = createConnection();119 connection.connect();120 //引入插入模块 121 require('./router/insert').insert(req,res,connection)122 console.log(req.query)123})124//根据hid获取酒店数据125app.get('/selecthid', function(req, res) {126 127 var connection = createConnection();128 connection.connect();129 //引入查找模块130 require('./router/select').selectId(req,res,connection);131 console.log(req.query)132}) 133//获取评论数134app.get('/selectcommon', function(req, res) {135 136 var connection = createConnection();137 connection.connect();138 //引入查找模块139 require('./router/select').selectCommon(req,res,connection);140 console.log(req.query)141})142//分页获取前端页面的商品数据143app.get('/selectpage', function(req, res) {144 145 var connection = createConnection();146 connection.connect();147 //引入查找模块148 require('./router/select').selectPage(req,res,connection);149 console.log(req.query)150}) 151 152//获取所有前端页面的商品数据153app.get('/selectAll', function(req, res) {154 155 var connection = createConnection();156 connection.connect();157 //引入查找模块158 require('./router/select').selectAll(req,res,connection);159 console.log(req.query)160})161//获取所有我发布的求租信息 余路的接口(不要在打错名字了各位)162app.get('/myrelease', function(req, res) {163 164 var connection = createConnection();165 connection.connect();166 //引入查找模块167 require('./router/myRelease').myRelease(req,res,connection);168 console.log(req.query)169}) 170//删除发布求租的信息 171app.get('/deleteRelease', function(req, res) {172 var connection = createConnection();173 connection.connect();174 //引入查找模块175 require('./router/deleteRelease').deleteRelease(req,res,connection);176 console.log(req.query)177}) 178//查找所有travel里面的东西179app.get('/selectTravel', function(req, res) {180 // 解决跨域181 //然后请求的很快的时候才能正常关闭链接、182 var connection = createConnection();183 connection.connect();184 //引入查找模块185 require('./router/select').selectTravel(req,res,connection);186 console.log(req.query)187}) 188// 每次查找十条酒店信息189app.get('/selecthotel', function(req, res) {190 // 解决跨域191 //然后请求的很快的时候才能正常关闭链接、192 var connection = createConnection();193 connection.connect();194 //引入查找模块195 require('./router/selecthotel').selecthotel(req,res,connection);196 console.log(req.query)197}) 198// 查找分享199app.get('/selectShare', function(req, res) {200 //然后请求的很快的时候才能正常关闭链接、201 var connection = createConnection();202 connection.connect();203 //引入查找模块204 require('./router/share').selectShare(req,res,connection);205 console.log(req.query)206}) 207 208// 酒店排序209app.get('/sorthotel', function(req, res) {210 //然后请求的很快的时候才能正常关闭链接、211 var connection = createConnection();212 connection.connect();213 //引入查找模块214 require('./router/sorthotel').sorthotel(req,res,connection);215 console.log(req.query)216}) 217//查找所有审核表单里的东西218app.get('/checkhomestay', function(req, res) {219 // 解决跨域220 //然后请求的很快的时候才能正常关闭链接、221 var connection = createConnection();222 connection.connect();223 //引入查找模块224 require('./router/select').checkhomestay(req,res,connection);225 console.log(req.query)226}) 227//获取所有workplan里面的东西228app.get('/getplan', function(req, res) {229 //然后请求的很快的时候才能正常关闭链接、230 var connection = createConnection();231 connection.connect();232 //引入查找模块233 require('./router/select').getplan(req,res,connection);234 console.log(req.query)235}) 236//获取所有admin里面的东西237app.get('/getadmin', function(req, res) {238 //然后请求的很快的时候才能正常关闭链接、239 var connection = createConnection();240 connection.connect();241 //引入查找模块242 require('./router/select').getadmin(req,res,connection);243 console.log(req.query)244}) 245//更新admin的员工评分246app.get('/changerate', function(req, res) {247 //然后请求的很快的时候才能正常关闭链接、248 var connection = createConnection();249 connection.connect();250 //引入查找模块251 require('./router/update').updaterare(req,res,connection);252 console.log(req.query)253}) 254//获取订单信息255app.get('/getorder', function(req, res) {256 //然后请求的很快的时候才能正常关闭链接、257 var connection = createConnection();258 connection.connect();259 //引入查找模块260 require('./router/orderlist').orderlist(req,res,connection);261 console.log(req.query)262}) 263//更新订单状态264app.get('/updateType', function(req, res) {265 var connection = createConnection();266 connection.connect();267 require('./router/update').updateType(req,res,connection);268 console.log(req.query)269}) 270//要post请求...............................................................................271// parse application/x-www-form-urlencoded 272//使用bodyParser模块273//用于post请求获取参数274var bodyParser = require('body-parser')275app.use(bodyParser.urlencoded({276 extended: false277}))278//鱼露279app.post('/release', function(req, res) {280 281 var connection = createConnection();282 connection.connect();283 //引入插入模块 284 require('./router/release').release(req,res,connection)285})286//注册管理者287app.post('/registeradmin', function(req, res) {288 // 解决跨域289 290 //然后请求的很快的时候才能正常关闭链接、291 var connection = createConnection();292 connection.connect();293 //引入插入模块 294 require('./router/register').registerAdmin(req,res,connection)295})296//验证登录者297app.post('/loginadmin', function(req, res) {298 // 解决跨域299 300 //然后请求的很快的时候才能正常关闭链接、301 var connection = createConnection();302 connection.connect();303 //引入插入模块 304 require('./router/register').loginAdmin(req,res,connection)305})306//赖俊豪写的307app.post('/userregister', function(req, res) {308 309 //然后请求的很快的时候才能正常关闭链接、310 var connection = createConnection();311 connection.connect();312 //引入插入模块 313 require('./router/userregister.js').userregister(req,res,connection)314})315app.post('/userchange', function(req, res) {316 var connection = createConnection();317 connection.connect();318 //引入插入模块 319 require('./router/userchange.js').userchange(req,res,connection)320})321//监听该端口..............................................................................322var server = app.listen(3000, function() {323 //测试324 //测试325 var host = server.address().address326 var port = server.address().port327 console.log("应用实例,访问地址为 http://%s:%s", host, port)...

Full Screen

Full Screen

test-createconnection-async.js

Source:test-createconnection-async.js Github

copy

Full Screen

...7var cfg = require('../config.js');8exports.mysql_libmysqlclient_createConnection_0 = function (test) {9 test.expect(1);10 test.throws(function () {11 cfg.mysql_libmysqlclient.createConnection();12 }, "require('mysql-libmysqlclient').createConnection() must get callback as last argument");13 test.done();14};15exports.mysql_libmysqlclient_createConnection_1_NoFunction = function (test) {16 test.expect(1);17 test.throws(function () {18 cfg.mysql_libmysqlclient.createConnection(cfg.host);19 }, "require('mysql-libmysqlclient').createConnection() must get callback as last argument");20 test.done();21};22exports.mysql_libmysqlclient_createConnection_1_Function = function (test) {23 test.expect(2);24 cfg.mysql_libmysqlclient.createConnection(function (err, conn) {25 test.ok(err === null, "Error object is not present");26 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");27 if (conn.connectedSync()) {28 conn.closeSync();29 }30 test.done();31 });32};33exports.mysql_libmysqlclient_createConnection_2 = function (test) {34 test.expect(3);35 cfg.mysql_libmysqlclient.createConnection(cfg.host, function (err, conn) {36 test.ok(err instanceof Error, "Error object is present");37 test.ok(!conn, "Connection object is not defined");38 test.ok(err.message.match(/Connection error.*Access denied for user/));39 test.done();40 });41};42exports.mysql_libmysqlclient_createConnection_3_Function = function (test) {43 test.expect(3);44 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, function (err, conn) {45 test.ok(err instanceof Error, "Error object is present");46 test.ok(!conn, "Connection object is not defined");47 var error = "Access denied for user '" + cfg.user + "'@'" + cfg.host + "' (using password: NO)";48 var errno = 1045;49 test.equals(err.message, "Connection error #" + errno + ": " + error, "Callback exception");50 if (conn && conn.connectedSync()) {51 conn.closeSync();52 }53 test.done();54 });55};56exports.mysql_libmysqlclient_createConnection_3_NoFunction = function (test) {57 test.expect(1);58 test.throws(function () {59 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, cfg.password);60 }, "require('mysql-libmysqlclient').createConnection() must get callback as last argument");61 test.done();62};63exports.mysql_libmysqlclient_createConnection_4 = function (test) {64 test.expect(2);65 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, cfg.password, function (err, conn) {66 test.ok(err === null, "Error object is not present");67 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");68 if (conn.connectedSync()) {69 conn.closeSync();70 }71 test.done();72 });73};74exports.mysql_libmysqlclient_createConnection_5_AccessAllowed = function (test) {75 test.expect(3);76 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, cfg.password, cfg.database, function (err, conn) {77 test.ok(err === null, "Error object is not present");78 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");79 var isConnected = conn.connectedSync();80 test.ok(isConnected, "cfg.mysql_libmysqlclient.createConnection(host, user, password, database, callback)");81 if (!isConnected) {82 // Extra debug output83 console.log("Error:" + conn.connectError);84 } else {85 conn.closeSync();86 }87 test.done();88 });89};90exports.mysql_libmysqlclient_createConnection_5_AccessDenied = function (test) {91 test.expect(3);92 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, cfg.password, cfg.database_denied, function (err, conn) {93 test.ok(err, "Error object is present");94 test.ok(!conn, "Connection object is not defined");95 var error = "Access denied for user '" + cfg.user + "'@'" + cfg.host + "' to database '" + cfg.database_denied + "'";96 var errno = 1044;97 test.equals(err.message, "Connection error #" + errno + ": " + error, "Callback exception");98 test.done();99 });100};101exports.mysql_libmysqlclient_createConnection_6 = function (test) {102 test.expect(3);103 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, cfg.password, cfg.database, cfg.port, function (err, conn) {104 test.ok(err === null, "Error object is not present");105 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");106 var isConnected = conn.connectedSync();107 test.ok(isConnected, "cfg.mysql_libmysqlclient.createConnection(host, user, password, database, flags, callback)");108 if (!isConnected) {109 // Extra debug output110 console.log("Error:" + conn.connectError);111 } else {112 conn.closeSync();113 }114 test.done();115 });116};117exports.mysql_libmysqlclient_createConnection_8 = function (test) {118 test.expect(3);119 var compress_flag = cfg.mysql_bindings.CLIENT_COMPRESS;120 cfg.mysql_libmysqlclient.createConnection(cfg.host, cfg.user, cfg.password, cfg.database, null, null, compress_flag, function (err, conn) {121 test.ok(err === null, "Error object is not present");122 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");123 var isConnected = conn.connectedSync();124 test.ok(isConnected, "cfg.mysql_libmysqlclient.createConnection(host, user, password, database, flags, callback)");125 if (!isConnected) {126 // Extra debug output127 console.log("Error:" + conn.connectError);128 } else {129 conn.closeSync();130 }131 test.done();132 });133};134exports.mysql_libmysqlclient_createConnectionSync_DSN_1 = function (test) {135 test.expect(3);136 var dsn = require('util').format("mysql://%s:%s@%s:%s", cfg.user, cfg.password, cfg.host, cfg.port);137 cfg.mysql_libmysqlclient.createConnection(dsn, function (err, conn) {138 test.ok(err === null, "Error object is not present");139 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");140 var isConnected = conn.connectedSync();141 test.ok(isConnected, "cfg.mysql_libmysqlclient.createConnection(dsn(user, password, host, port), callback)");142 if (!isConnected) {143 // Extra debug output144 console.log("Error:" + conn.connectError);145 } else {146 conn.closeSync();147 }148 test.done();149 });150};151exports.mysql_libmysqlclient_createConnectionSync_DSN_2 = function (test) {152 test.expect(3);153 var dsn = require('util').format("mysql://%s:%s@%s:%s?qwerty=1234", cfg.user, cfg.password, cfg.host, cfg.port);154 cfg.mysql_libmysqlclient.createConnection(dsn, function (err, conn) {155 test.ok(err === null, "Error object is not present");156 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");157 var isConnected = conn.connectedSync();158 test.ok(isConnected, "cfg.mysql_libmysqlclient.createConnection(dsn(user, password, host, port), callback)");159 if (!isConnected) {160 // Extra debug output161 console.log("Error:" + conn.connectError);162 } else {163 conn.closeSync();164 }165 test.done();166 });167};168exports.mysql_libmysqlclient_createConnectionSync_DSN_3 = function (test) {169 test.expect(3);170 var dsn = require('util').format("mysql://%s:%s@%s:%s/%s/zxcvbn?qwerty=1234", cfg.user, cfg.password, cfg.host, cfg.port, cfg.database);171 cfg.mysql_libmysqlclient.createConnection(dsn, function (err, conn) {172 test.ok(err === null, "Error object is not present");173 test.ok(conn instanceof cfg.mysql_bindings.MysqlConnection, "conn instanceof MysqlConnection");174 var isConnected = conn.connectedSync();175 test.ok(isConnected, "cfg.mysql_libmysqlclient.createConnection(dsn(user, password, host, port, database), callback)");176 if (!isConnected) {177 // Extra debug output178 console.log("Error:" + conn.connectError);179 } else {180 conn.closeSync();181 }182 test.done();183 });...

Full Screen

Full Screen

client.js

Source:client.js Github

copy

Full Screen

...128};129//130// ### function createConnection (options)131//132proto.createConnection = function createConnection(options) {133 if (!options)134 options = {};135 var state = this._spdyState;136 var stream = new spdy.Stream(state.connection, {137 id: state.id,138 priority: options.priority || 7,139 client: true,140 decompress: options.spdy.decompress == undefined ? true :141 options.spdy.decompress142 });143 state.id += 2;144 state.connection._addStream(stream);145 return stream;146};...

Full Screen

Full Screen

getdata.js

Source:getdata.js Github

copy

Full Screen

...5var createConnection = require("../createConnection.js")6router.post('/indexbanner', function (req, res, next) {7 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域8 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码9 createConnection(`select * from index_banner where type='${req.body.type}'`, function (results) {10 res.send(results);11 });12});13router.post('/indexblist', function (req, res, next) {14 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域15 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码16 createConnection(`select * from index_booklist where type='${req.body.type}'`, function (results) {17 res.send(results);18 });19});20router.post('/getbanner', function (req, res, next) {21 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域22 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码23 createConnection(`select * from autoplay where type='${req.body.type}'`, function (results) {24 res.send(results);25 });26});27router.post('/latelyupdate', function (req, res, next) {28 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域29 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码30 createConnection(`select * from index_lately_update`, function (results) {31 res.send(results);32 });33});34router.post('/indextop', function (req, res, next) {35 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域36 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码37 createConnection(`select * from index_top where type='${req.body.type}'`, function (results) {38 res.send(results);39 });40});41router.post('/getbookinfo', function (req, res, next) {42 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域43 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码44 createConnection(`select * from book_info where book_id_curr='${req.body.actionid}'`, function (results) {45 res.send(results);46 });47});48router.post('/getdata2', function (req, res, next) {49 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域50 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码51 createConnection(`select * from index_top`, function (results) {52 res.send(results);53 });54});55router.post('/getdata1', function (req, res, next) {56 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域57 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码58 createConnection(`select * from autoplay`, function (results) {59 res.send(results);60 });61});62router.post('/getdata3', function (req, res, next) {63 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域64 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码65 createConnection(`select * from index_lately_update`, function (results) {66 res.send(results);67 });68});69router.post('/getdata4', function (req, res, next) {70 res.setHeader("Access-Control-Allow-Origin", "*");//允许跨域71 res.setHeader("Content-Type", "text/plain;charset=UTF-8");//字符编码72 createConnection(`select * from index_booklist`, function (results) {73 res.send(results);74 });75});...

Full Screen

Full Screen

Database.test.js

Source:Database.test.js Github

copy

Full Screen

...16// const connection = {};17// // createConnection = jest.fn(async () => connection);18// const config = {};19// const db = new Database(config);20// return expect(db.createConnection()).resolves.toBe(connection);21// });22// it('Creates a connection with the databases config', async () => {23// const connection = {};24// createConnection = jest.fn(async () => connection);25// const config = {};26// const db = new Database(config);27// await db.createConnection();28// expect(createConnection).toBeCalledWith(config);29// expect(createConnection).toBeCalledTimes(1);30// });31// it('Stores the connection internally', async () => {32// const connection = {};33// createConnection = jest.fn(async () => connection);34// const config = {};35// const db = new Database(config);36// await db.createConnection();37// expect(db.connection).toBe(connection);38// });39// });40// describe('Get connection always returns a connection object.', () => {41// it('returns a connection object when only just initialized.', async () => {42// const connection = {};43// createConnection = jest.fn(async () => connection);44// const config = {};45// const db = new Database(config);46// const conn = await db.getConnection();47// expect(conn).toBe(connection);48// });49// it('returns the same connection object after creating it.', async () => {50// const connection = {};...

Full Screen

Full Screen

transport_lists_spec.js

Source:transport_lists_spec.js Github

copy

Full Screen

1describe("Transport lists", function() {2 var _isReady = Pusher.isReady;3 beforeEach(function() {4 spyOn(Pusher.WSTransport, "isSupported").andReturn(true);5 spyOn(Pusher.FlashTransport, "isSupported").andReturn(true);6 spyOn(Pusher.SockJSTransport, "isSupported").andReturn(true);7 spyOn(Pusher.WSTransport, "createConnection")8 .andCallFake(Pusher.Mocks.getTransport);9 spyOn(Pusher.FlashTransport, "createConnection")10 .andCallFake(Pusher.Mocks.getTransport);11 spyOn(Pusher.SockJSTransport, "createConnection")12 .andCallFake(Pusher.Mocks.getTransport);13 spyOn(Pusher, "getDefaultStrategy").andCallFake(function() {14 return [15 [":def_transport", "a", "ws", 1, {}],16 [":def_transport", "b", "flash", 2, {}],17 [":def_transport", "c", "sockjs", 3, {}],18 [":def", "strategy", [":best_connected_ever", ":a", ":b", ":c"]]19 ];20 });21 spyOn(Pusher.Network, "isOnline").andReturn(true);22 Pusher.isReady = true;23 });24 afterEach(function() {25 Pusher.isReady = _isReady;26 });27 it("should use all transports if the whitelist is not specified", function() {28 var pusher = new Pusher("asdf", { disableStats: true });29 expect(Pusher.WSTransport.createConnection).toHaveBeenCalled();30 expect(Pusher.FlashTransport.createConnection).toHaveBeenCalled();31 expect(Pusher.SockJSTransport.createConnection).toHaveBeenCalled();32 pusher.disconnect();33 });34 it("should not use any transports if the whitelist is empty", function() {35 var pusher = new Pusher("asdf", {36 disableStats: true,37 enabledTransports: []38 });39 expect(Pusher.WSTransport.createConnection).not.toHaveBeenCalled();40 expect(Pusher.FlashTransport.createConnection).not.toHaveBeenCalled();41 expect(Pusher.SockJSTransport.createConnection).not.toHaveBeenCalled();42 pusher.disconnect();43 });44 it("should use only transports from the whitelist", function() {45 var pusher = new Pusher("asdf", {46 disableStats: true,47 enabledTransports: ["a", "c"]48 });49 expect(Pusher.WSTransport.createConnection).toHaveBeenCalled();50 expect(Pusher.FlashTransport.createConnection).not.toHaveBeenCalled();51 expect(Pusher.SockJSTransport.createConnection).toHaveBeenCalled();52 pusher.disconnect();53 });54 it("should not use transports from the blacklist", function() {55 var pusher = new Pusher("asdf", {56 disableStats: true,57 disabledTransports: ["a", "b"]58 });59 expect(Pusher.WSTransport.createConnection).not.toHaveBeenCalled();60 expect(Pusher.FlashTransport.createConnection).not.toHaveBeenCalled();61 expect(Pusher.SockJSTransport.createConnection).toHaveBeenCalled();62 pusher.disconnect();63 });64 it("should not use transports from the blacklist, even if they are on the whitelist", function() {65 var pusher = new Pusher("asdf", {66 disableStats: true,67 enabledTransports: ["b", "c"],68 disabledTransports: ["b"]69 });70 expect(Pusher.WSTransport.createConnection).not.toHaveBeenCalled();71 expect(Pusher.FlashTransport.createConnection).not.toHaveBeenCalled();72 expect(Pusher.SockJSTransport.createConnection).toHaveBeenCalled();73 pusher.disconnect();74 });...

Full Screen

Full Screen

test-net-create-connection.js

Source:test-net-create-connection.js Github

copy

Full Screen

...17 ++clientConnected;18 }19 function fail(opts, errtype, msg) {20 assert.throws(function() {21 var client = net.createConnection(opts, cb);22 }, function(err) {23 return err instanceof errtype && msg === err.message;24 });25 }26 net.createConnection(tcpPort).on('connect', cb);27 net.createConnection(tcpPort, 'localhost').on('connect', cb);28 net.createConnection(tcpPort, cb);29 net.createConnection(tcpPort, 'localhost', cb);30 net.createConnection(tcpPort + '', 'localhost', cb);31 net.createConnection({port: tcpPort + ''}).on('connect', cb);32 net.createConnection({port: '0x' + tcpPort.toString(16)}, cb);33 fail({34 port: true35 }, TypeError, 'port should be a number or string: true');36 fail({37 port: false38 }, TypeError, 'port should be a number or string: false');39 fail({40 port: []41 }, TypeError, 'port should be a number or string: ');42 fail({43 port: {}44 }, TypeError, 'port should be a number or string: [object Object]');45 fail({46 port: null47 }, TypeError, 'port should be a number or string: null');48 fail({49 port: ''50 }, RangeError, 'port should be >= 0 and < 65536: ');51 fail({52 port: ' '53 }, RangeError, 'port should be >= 0 and < 65536: ');54 fail({55 port: '0x'56 }, RangeError, 'port should be >= 0 and < 65536: 0x');57 fail({58 port: '-0x1'59 }, RangeError, 'port should be >= 0 and < 65536: -0x1');60 fail({61 port: NaN62 }, RangeError, 'port should be >= 0 and < 65536: NaN');63 fail({64 port: Infinity65 }, RangeError, 'port should be >= 0 and < 65536: Infinity');66 fail({67 port: -168 }, RangeError, 'port should be >= 0 and < 65536: -1');69 fail({70 port: 6553671 }, RangeError, 'port should be >= 0 and < 65536: 65536');72});73// Try connecting to random ports, but do so once the server is closed74server.on('close', function() {75 function nop() {}76 net.createConnection({port: 0}).on('error', nop);77 net.createConnection({port: undefined}).on('error', nop);78});79process.on('exit', function() {80 assert.equal(clientConnected, expectedConnections);...

Full Screen

Full Screen

test-http-createConnection.js

Source:test-http-createConnection.js Github

copy

Full Screen

...29 });30 });31 });32});33function createConnection() {34 return net.createConnection(server.address().port, '127.0.0.1');35}36function createConnectionAsync(options, cb) {37 setImmediate(function() {38 cb(null, net.createConnection(server.address().port, '127.0.0.1'));39 });40}41function createConnectionBoth1(options, cb) {42 const socket = net.createConnection(server.address().port, '127.0.0.1');43 setImmediate(function() {44 cb(null, socket);45 });46 return socket;47}48function createConnectionBoth2(options, cb) {49 const socket = net.createConnection(server.address().port, '127.0.0.1');50 cb(null, socket);51 return socket;52}53function createConnectionError(options, cb) {54 process.nextTick(cb, new Error('Could not create socket'));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2stfConnection.devices().then(function(devices) {3 console.log(devices);4});5var stf = require('devicefarmer-stf');6stfConnection.devices().then(function(devices) {7 console.log(devices);8});9var stf = require('devicefarmer-stf');10stfConnection.devices().then(function(devices) {11 console.log(devices);12});13var stf = require('devicefarmer-stf');14stfConnection.devices().then(function(devices) {15 console.log(devices);16});17var stf = require('devicefarmer-stf');18stfConnection.devices().then(function(devices) {19 console.log(devices);20});21var stf = require('devicefarmer-stf');22stfConnection.devices().then(function(devices) {23 console.log(devices);24});25var stf = require('devicefarmer-stf');26stfConnection.devices().then(function(devices) {27 console.log(devices);28});29var stf = require('devicefarmer-stf');30stfConnection.devices().then(function(devices) {31 console.log(devices);32});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var device = stf.createConnection();3device.connect();4var stf = require('devicefarmer-stf');5var device = stf.createConnection();6device.connect();7var stf = require('devicefarmer-stf');8var device = stf.createConnection();9device.connect();10var stf = require('devicefarmer-stf');11var device = stf.createConnection();12device.connect();13var stf = require('devicefarmer-stf');14var device = stf.createConnection();15device.connect();16var stf = require('devicefarmer-stf');17var device = stf.createConnection();18device.connect();19var stf = require('devicefarmer-stf');20var device = stf.createConnection();21device.connect();22var stf = require('devicefarmer-stf');23var device = stf.createConnection();24device.connect();25var stf = require('devicefarmer-stf');26var device = stf.createConnection();27device.connect();28var stf = require('devicefarmer-stf');29var device = stf.createConnection();30device.connect();31var stf = require('devicefarmer-stf');32var device = stf.createConnection();33device.connect();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful