How to use getServer method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

api.js

Source:api.js Github

copy

Full Screen

...4 * @param url        请求网址5 * @param callback   回掉函数6 * @param data       请求参数 json格式7 */8function  getServer( url,callback , data ,hideLoading )9{10    if(!hideLoading)11    var loading = $.loading();12    typeof (data) == 'undefined' ? data={} : '';13    if( typeof  callback !="function" )14    {   callback = function () {  alert('success');}; }15    var request = {};16    if(!_csrf_token) console.log('Set token !!!!');17    request['_csrf-frontend'] = _csrf_token;18    request.data = data;1920    $.ajax({21        url:url,22        data:request,23        dataType:'json',24        type:'post',25        success:function(response){  callback(response);  $.closeLoading(loading);  },26        error:function () {27            $.closeLoading(loading);28            alert(url+"  not found !!");29        }30    });31}3233function errorTip(msg) {34    msg?'':msg='';35    $.waring('执行失败'+msg);36}37function succesTip(msg) {38    $.alert('success'+msg);39}40function makeParseResultFun(msg, errormsg) {4142    if(msg==undefined) msg='成功';43    if(errormsg==undefined) errormsg='执行失败';44    return function(response) {45        console.log(response)46        if(response.status=='1')47        {48            $.alert(msg);49        }else50        {51            $.waring(errormsg);52        }53    }5455}5657function GetQueryString(name)58{59    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");60    var r = window.location.search.substr(1).match(reg);61    if(r!=null)return  unescape(r[2]); return null;62}6364UserService ={65    login : function (username,password ,remeberMe ,callback) {66        var url =  '/site/login';67        if(! /[\w_@]{3,20}/.test(username) )68        {69            callback( { msg:'用户名不合法'} );70            return71        }72        if(!/[\w_@]{5,20}/.test(password))73        {74            callback({ msg:'密码不合法'});75            return;76        }77        remeberMe = remeberMe? true : false;78        var data = {79            username : username,80            password : password,81            remoberMe:remeberMe82        }83        getServer(url ,callback , data);84    },85    signup : function (email,username,password  ,callback) {86        var url =  '/site/signup';87        if(! /[\w_@]{3,20}/.test(username) )88        {89            callback( { msg:'用户名不合法'} );  return90        }91        if(!/[\w_@]{5,20}/.test(password))92        {93            callback({ msg:'密码不合法'}); return;94        }95        if(!/[\w_]{5,40}@\w{1,10}\.\w{1,10}/.test(email))96        {97            callback({ msg:'邮箱格式有问题'}); return;98        }99100101        var data = {102            email :  email,103            nickname : username,104            password : password,105        }106        console.log(data)107        getServer(url ,callback , data);108    },109    logout: function () {110        callback = function (response) {111            if(response.status==1)112            {113                window.location.href = '/';114            }115        }116        getServer("/site/logout" ,callback );117    },118    updateSetting: function (data , callback) {119        var url =  '/user/setting';120        getServer(url ,callback , data);121    }122}123124IndexService = {125    getData: function (callback , data) {126        var url =  '/index/get-index';127        getServer(url ,callback , data);128    },129    getIndex: function () {130        /*加载数据*/131        $.ajax({132            type:'GET',133            url:'/index/get-lesson-desc',134            dataType:"json",135            success:function (response) {136                //console.log(response.data);137                var data = response.data;138139                var t1 = '<div alt="高数" class="slide_page">\140                                    <img src="images/page_1.png">\141                                   <div class="course_desc">\142                                   </div> </div>';143144                var t2_start = '<ul> ';145                var t2_end = '</ul> <div class="clear"></div>';146                //console.log(data);147                for (var j in data)148                {   //遍历分类 一页149                    var lessons = data[j]['lessons'];150                    var type    = data[j]['type'];151                    var page = $(t1);152                    //153                    for (var lvl2 in lessons)154                    { ////该分类下的课程155                        var course_desc = page.find(".course_desc");156                        var lesson = lessons[lvl2];157                        //console.log(lesson);158                        {159                            var courses_str=t2_start;160                            var chapters =lessons[lvl2].chapters;161                            for(var i in  chapters )162                            {163                                courses_str+='<li>'+chapters[i]+'</li>';164                            }165                            courses_str+=t2_end;166                            //console.log(courses_str);167                            course_desc.append(courses_str);168                        }169                    }170171                    page.attr("alt",type);172                    $("#kit-slideshow").append(page);173                }174175            },176            erros:function () {177                alter('error');178            }179        });180    }181}182183DetalService ={184    getData: function (callback , data) {185        var url =  '/detal/get-detal';186        getServer(url ,callback , data);187    },188}189190ChapterService = {191    importChapter: function (callback , data) {192        var url =  '/chapter/import-chapter';193        getServer(url ,callback , data);194    }195    ,196    getChapter: function (callback , data) {197        var url =  '/chapter/get-chapter';198        getServer(url ,callback , data);199    }200    ,201    getRootChapterByTag: function (callback , data) {202        var url =  '/chapter/get-root-chapter-by-tag';203        getServer(url ,callback , data);204    }205    ,206    createChapterNode: function (callback ,data) {207        var url = '/chapter/create-chapter-node';208        getServer(url ,callback , data);209    }210    ,211    moveNode: function (callback ,data) {212        var url = '/chapter/move-node';213        getServer(url ,callback , data);214    }215    ,216    updateNode :function (callback ,data) {217        var url = '/chapter/update-chapter-node';218        getServer(url ,callback , data);219    }220    ,221    deleteChapterNode: function(callback ,data){222        var url = '/chapter/del-chapter-node';223        getServer(url ,callback , data);224    },225    getTagTree:function (callback ,data) {226        var url = '/chapter/get-tag-tree';227        getServer(url ,callback , data);228    }229    ,230    joinCourse: function ( callback , data ) {231        var url = '/chapter/join-course';232        getServer(url ,callback , data);233    }234}235236CategoryService = {237    getNode: function (callback , data) {238        var url =  '/category/get-node';239        getServer(url ,callback , data);240    },241    createNode: function (callback ,data ) {242        var url = '/category/create-node';243        getServer(url ,callback , data);244    },245    updateNode :function (callback ,data) {246        var url = '/category/update-node';247        getServer(url ,callback , data);248    },249    deleteNode: function(callback ,data){250        var url = '/category/del-node';251        getServer(url ,callback , data);252    },253    moveNode : function (callback,data) {254        var url = '/category/move-node';255        getServer(url ,callback , data);256    }257}258259PointService = {260    getPointListByChapter:function (callback,data) {261        var url = '/point/get-point-by-chapter';262        getServer(url ,callback , data);263    },264    createArticle: function (callback ,data) {265        var url = '/point/create-ajax';266        getServer(url ,callback , data);267    },268    getArticleList:function (callback,data) {269        var url = '/point/get-article-list';270        getServer(url ,callback , data);271    },272    getArticleListByTag:function (callback,data) {273        var url = '/point/get-article-by-tag';274        getServer(url ,callback , data);275    },276    getArticleListByHot:function (callback,data) {277        var url = '/point/get-article-by-hot';278        getServer(url ,callback , data);279    },280    getArticleListByUser:function (callback,data) {281        var url = '/point/get-article-by-tag';282        getServer(url ,callback , data);283    },284    getRecomendArticle:function (callback,data) {285        var url = '/point/get-article-by-recommend';286        getServer(url ,callback , data);287    },288    getArticleListByKeyWord:function (callback,data) {289        var url = '/point/get-article-by-keyword';290        getServer(url ,callback , data);291    },292    getAriticleDetal:function (callback,data) {293        var  url ="/point/get-article-detal";294        getServer(url,callback,data);295    }296}297298ArticleService = {299    createArticle: function (callback ,data) {300        var url = '/article/create-ajax';301        getServer(url ,callback , data);302    },303    getArticleList:function (callback,data) {304        var url = '/article/get-article-list';305        getServer(url ,callback , data);306    },307    getArticleListByChapter:function (callback,data) {308        var url = '/article/get-article-by-chapter';309        getServer(url ,callback , data);310    },311    getArticleListByHot:function (callback,data) {312        var url = '/article/get-article-by-hot';313        getServer(url ,callback , data);314    },315    getArticleListByUser:function (callback,data) {316        var url = '/article/get-article-by-tag';317        getServer(url ,callback , data);318    },319    getRecomendArticle:function (callback,data) {320        var url = '/article/get-article-by-recommend';321        getServer(url ,callback , data);322    },323    getArticleListByKeyWord:function (callback,data) {324        var url = '/article/get-article-by-keyword';325        getServer(url ,callback , data);326    },327    getAriticleDetal:function (callback,data) {328        var  url ="/article/get-article-detal";329        getServer(url,callback,data);330    }331}332333/**334 *   评论335 * */336CommentService = {337    createComment: function (callback ,data) {338        var url = '/comment/create-ajax';339        getServer(url ,callback , data);340    },341    getCommentList:function (callback,data) {342        var url = '/comment/get-comment-list';343        getServer(url ,callback , data);344    },345    getCommentListByTag:function (callback,data) {346        var url = '/comment/get-comment-by-tag';347        getServer(url ,callback , data);348    },349    getCommentListByHot:function (callback,data) {350        var url = '/comment/get-comment-by-tag';351        getServer(url ,callback , data);352    },353    getCommentListByUser:function (callback,data) {354        var url = '/comment/get-comment-by-tag';355        getServer(url ,callback , data);356    },357    getRecomendComment:function (callback,data) {358        var url = '/comment/get-comment-by-tag';359        getServer(url ,callback , data);360    },361    getCommentListByKeyWord:function (callback,data) {362        var url = '/comment/get-comment-by-tag';363        getServer(url ,callback , data);364    },365    getCommentDetal:function (callback,data) {366        var  url ="/comment/get-comment-detal";367        getServer(url,callback,data);368    }369}370371/**372 * 帖子接口·373 * */374PostService = {375    createPost: function (callback ,data) {376        var url = '/post/create-ajax';377        getServer(url ,callback , data);378    },379    getPostList:function (callback,data) {380        var url = '/post/get-post-list';381        getServer(url ,callback , data);382    },383    getPostListByTag:function (callback,data) {384        var url = '/post/get-post-by-tag';385        getServer(url ,callback , data);386    },387    getPostListByHot:function (callback,data) {388        var url = '/post/get-post-by-tag';389        getServer(url ,callback , data);390    },391    getPostListByUser:function (callback,data) {392        var url = '/post/get-post-by-tag';393        getServer(url ,callback , data);394    },395    getRecomendPost:function (callback,data) {396        var url = '/post/get-post-by-tag';397        getServer(url ,callback , data);398    },399    getPostListByKeyWord:function (callback,data) {400        var url = '/post/get-post-by-tag';401        getServer(url ,callback , data);402    },403    getPostDetal:function (callback,data) {404        var  url ="/post/get-post-detal";405        getServer(url,callback,data);406    }407}408409/**410 * 试卷接口·411 * */412PaperService = {413    getPaperListByChapter:function (callback,data) {414        var url = '/paper/get-paper-by-chapter';415        getServer(url ,callback , data);416    },417    createExam: function (callback ,data) {418        var url = '/exam/create-ajax';419        getServer(url ,callback , data);420    },421    getExamList:function (callback,data) {422        var url = '/exam/get-exam-list';423        getServer(url ,callback , data);424    },425426    getExamListByUser:function (callback,data) {427        var url = '/exam/get-exam-by-tag';428        getServer(url ,callback , data);429    },430    getRecomendExam:function (callback,data) {431        var url = '/exam/get-exam-by-tag';432        getServer(url ,callback , data);433    },434}435436/**437 * 资料438 * */439MaterialService = {440    getMateriaListByChapter:function (callback,data) {441        var url = '/material/get-material-by-chapter';442        getServer(url ,callback , data);443    },444    createMaterial :function (callback ,data) {445        var url = '/material/create-ajax';446        getServer(url ,callback , data);447    },448    deleteMaterial :function (callback ,data) {449        var url = '/material/delete-material';450        getServer(url ,callback , data);451    },452}453454VideoService = {455    getVideoListByChapter:function (callback,data) {456        var url = '/video/get-video-by-chapter';457        getServer(url ,callback , data);458    },459    createVideo :function (callback ,data) {460        var url = '/video/create-ajax';461        getServer(url ,callback , data);462    },463    getVideoDetal:function (callback ,data) {464        var url = '/video/get-video-detal';465        getServer(url ,callback , data);466    },467    updateVideo :function (callback ,data) {468        var url = '/video/update-Video';469        getServer(url ,callback , data);470    },471    getVideoList :function (callback ,data) {472        var url = '/video/get-video-list';473        getServer(url ,callback , data);474    },475    deleteVideo :function (callback ,data) {476        var url = '/video/delete-video';477        getServer(url ,callback , data);478    },479    getRecommentVideoList :function (callback ,data) {480        var url = '/video/get-video-list';481        getServer(url ,callback , data);482    },483484}485486UploaderServer = function (param) {487    var  server ={488        uploaderId:'',489        //上传回掉方法490        onProgress : function (evt) {491            var loaded = evt.loaded;     //已经上传大小情况492            var tot    = evt.total;      //附件总大小493            var per    = Math.floor(100*loaded/tot);  //已经上传的百分比494            // console.log(per);495            $(".progress-bar").css("width" , per +"%");
...

Full Screen

Full Screen

index.spec.js

Source:index.spec.js Github

copy

Full Screen

1const test = require('ava')2const helpers = require('./_helpers')3test('get the url of a named route', async (t) => {4  const server = await helpers.getServer()5  server.route({6    method: 'GET',7    path: '/foo',8    config: {9      id: 'foo',10      handler (request) {11        return request.aka('foo')12      }13    }14  })15  const res = await server.inject('/foo')16  t.is(res.payload, 'http://localhost:1337/foo')17})18test('get the url of a named route on custom router', async t => {19  const server = await helpers.getServer()20  const customRouter = await helpers.getRouter()21  customRouter.add({22    id: 'bar',23    method: 'GET',24    path: '/bar'25  })26  server.route({27    method: 'GET',28    path: '/foo',29    config: {30      id: 'foo',31      handler (request) {32        return request.aka('bar', {}, { router: customRouter })33      }34    }35  })36  const res = await server.inject('/foo')37  t.is(res.payload, 'http://localhost:1337/bar')38})39test('throw if no route matches', async (t) => {40  const server = await helpers.getServer()41  server.route({42    method: 'GET',43    path: '/',44    handler (request) {45      return request.aka('foo')46    }47  })48  const res = await server.inject('/')49  t.is(res.statusCode, 404)50  t.is(res.statusMessage, 'Not Found')51})52test('throw if no route matches on custom router', async t => {53  const server = await helpers.getServer()54  const customRouter = await helpers.getRouter()55  server.route({56    method: 'GET',57    path: '/',58    handler (request) {59      return request.aka('foo', {}, { router: customRouter })60    }61  })62  const res = await server.inject('/')63  t.is(res.statusCode, 404)64  t.is(res.statusMessage, 'Not Found')65})66test('throw if there is a missing parameter', async (t) => {67  const server = await helpers.getServer()68  server.route({69    method: 'GET',70    path: '/{name}',71    config: {72      id: 'foo',73      handler (request) {74        return request.aka('foo')75      }76    }77  })78  const res = await server.inject('/bar')79  t.is(res.statusCode, 400)80  t.is(res.statusMessage, 'Bad Request')81})82test('throw if there is s a mismatch in number of parameters required and given', async (t) => {83  const server = await helpers.getServer()84  server.route({85    method: 'GET',86    path: '/{greet}/{object}',87    config: {88      id: 'foo',89      handler (request) {90        return request.aka('foo', { params: { greet: 'hello' } })91      }92    }93  })94  const res = await server.inject('/hello/world')95  t.is(res.statusCode, 400)96  t.is(res.statusMessage, 'Bad Request')97})98test('place multiple parameters in the url', async (t) => {99  const server = await helpers.getServer()100  server.route({101    method: 'GET',102    path: '/{greet}/{object}',103    config: {104      id: 'foo',105      handler (request) {106        return request.aka('foo', { params: { greet: 'hello', object: 'world' } })107      }108    }109  })110  const res = await server.inject('/hello/world')111  t.is(res.payload, 'http://localhost:1337/hello/world')112})113test('places wildcard parameter in the url', async (t) => {114  const server = await helpers.getServer()115  server.route({116    method: 'GET',117    path: '/{path*}',118    config: {119      id: 'foo',120      handler (request) {121        return request.aka('foo', { params: { path: 'hello/world' } })122      }123    }124  })125  const res = await server.inject('/hello/world')126  t.is(res.payload, 'http://localhost:1337/hello/world')127})128test('places wildcard parameter in a url with more segments', async (t) => {129  const server = await helpers.getServer()130  server.route({131    method: 'GET',132    path: '/longer-path/{path*}',133    config: {134      id: 'foo',135      handler (request) {136        return request.aka('foo', { params: { path: 'hello/world' } })137      }138    }139  })140  const res = await server.inject('/longer-path/hello/world')141  t.is(res.payload, 'http://localhost:1337/longer-path/hello/world')142})143test('treats wildcard parameter as optional', async (t) => {144  const server = await helpers.getServer()145  server.route({146    method: 'GET',147    path: '/{path*}',148    config: {149      id: 'foo',150      handler (request) {151        return request.aka('foo')152      }153    }154  })155  const res = await server.inject('/')156  t.is(res.payload, 'http://localhost:1337')157})158test('treats wildcard parameter as optional in a url with more segments', async (t) => {159  const server = await helpers.getServer()160  server.route({161    method: 'GET',162    path: '/longer-path/{path*}',163    config: {164      id: 'foo',165      handler (request) {166        return request.aka('foo')167      }168    }169  })170  const res = await server.inject('/longer-path')171  t.is(res.payload, 'http://localhost:1337/longer-path')172})173test('places multiple wildcard parameters', async (t) => {174  const server = await helpers.getServer()175  server.route({176    method: 'GET',177    path: '/{path*3}',178    config: {179      id: 'foo',180      handler (request) {181        return request.aka('foo', { params: { path: ['hello', 'foo', 'bar'] } })182      }183    }184  })185  const res = await server.inject('/hello/foo/bar')186  t.is(res.payload, 'http://localhost:1337/hello/foo/bar')187})188test('throw if number of parameters mismatches the multiplier', async (t) => {189  const server = await helpers.getServer()190  server.route({191    method: 'GET',192    path: '/{path*3}',193    config: {194      id: 'foo',195      handler (request) {196        return request.aka('foo', { params: { path: ['hello', 'foo'] } })197      }198    }199  })200  const res = await server.inject('/hello/foo/bar')201  t.is(res.statusCode, 400)202  t.is(res.statusMessage, 'Bad Request')203})204test('strip optional params from path if none specified', async (t) => {205  const server = await helpers.getServer()206  server.route({207    method: 'GET',208    path: '/foobar/{param?}',209    config: {210      id: 'foo',211      handler (request) {212        return request.aka('foo')213      }214    }215  })216  const res = await server.inject('/foobar')217  t.is(res.payload, 'http://localhost:1337/foobar')218})219test('strip trailing slash after stripping optional parameters', async (t) => {220  const server = await helpers.getServer()221  server.route({222    method: 'GET',223    path: '/{param?}',224    config: {225      id: 'foo',226      handler (request) {227        return request.aka('foo')228      }229    }230  })231  const res = await server.inject('/')232  t.is(res.payload, 'http://localhost:1337')233})234test('append a query string', async (t) => {235  const server = await helpers.getServer()236  server.route({237    method: 'GET',238    path: '/foobar',239    config: {240      id: 'foo',241      handler (request) {242        return request.aka('foo', {243          query: {244            greet: 'hello',245            object: 'world'246          }247        })248      }249    }250  })251  const res = await server.inject('/foobar')252  t.is(res.payload, 'http://localhost:1337/foobar?greet=hello&object=world')253})254test('strips a trailing question mark if query paramter is undefined', async (t) => {255  const server = await helpers.getServer()256  server.route({257    method: 'GET',258    path: '/foobar',259    config: {260      id: 'foo',261      handler (request) {262        return request.aka('foo', {263          query: {264            greet: undefined265          }266        })267      }268    }269  })270  const res = await server.inject('/foobar')271  t.is(res.payload, 'http://localhost:1337/foobar')272})273test('server method for relative uri is accessible', async (t) => {274  const server = await helpers.getServer()275  server.route({276    method: 'GET',277    path: '/foo',278    config: {279      id: 'foo',280      handler (request) {}281    }282  })283  t.is(server.aka('foo'), '/foo')...

Full Screen

Full Screen

init.spec.js

Source:init.spec.js Github

copy

Full Screen

1const test = require('ava')2const helpers = require('./_helpers')3require('events').EventEmitter.defaultMaxListeners = 504test('throw error if plugin gets registered twice', async (t) => {5  await helpers.getServer()6  await t.throwsAsync(helpers.registerPlugin())7})8test('throw error if own options are invalid – colored', async (t) => {9  await t.throwsAsync(helpers.getServer({10    colored: null11  }))12  await t.throwsAsync(helpers.getServer({13    colored: 4214  }))15  await t.throwsAsync(helpers.getServer({16    colored: ''17  }))18  await t.throwsAsync(helpers.getServer({19    colored: 'foobar'20  }))21  await t.throwsAsync(helpers.getServer({22    colored: NaN23  }))24  await t.throwsAsync(helpers.getServer({25    colored: {}26  }))27  await t.throwsAsync(helpers.getServer({28    colored: []29  }))30  await t.throwsAsync(helpers.getServer({31    colored: new RegExp()32  }))33})34test('throw error if own options are invalid – override', async (t) => {35  await t.throwsAsync(helpers.getServer({36    override: null37  }))38  await t.throwsAsync(helpers.getServer({39    override: 4240  }))41  await t.throwsAsync(helpers.getServer({42    override: ''43  }))44  await t.throwsAsync(helpers.getServer({45    override: 'foobar'46  }))47  await t.throwsAsync(helpers.getServer({48    override: NaN49  }))50  await t.throwsAsync(helpers.getServer({51    override: {}52  }))53  await t.throwsAsync(helpers.getServer({54    override: []55  }))56  await t.throwsAsync(helpers.getServer({57    override: new RegExp()58  }))59})60test('throw error if own options are invalid – indent', async (t) => {61  await t.throwsAsync(helpers.getServer({62    indent: null63  }))64  await t.throwsAsync(helpers.getServer({65    indent: false66  }))67  await t.throwsAsync(helpers.getServer({68    indent: NaN69  }))70  await t.throwsAsync(helpers.getServer({71    indent: {}72  }))73  await t.throwsAsync(helpers.getServer({74    indent: []75  }))76  await t.throwsAsync(helpers.getServer({77    indent: new RegExp()78  }))79})80test('throw error if own options are invalid – preformatter', async (t) => {81  await t.throwsAsync(helpers.getServer({82    preformatter: (a, b, c) => ({ a, b, c })83  }))84  await t.throwsAsync(helpers.getServer({85    preformatter: null86  }))87  await t.throwsAsync(helpers.getServer({88    preformatter: false89  }))90  await t.throwsAsync(helpers.getServer({91    preformatter: NaN92  }))93  await t.throwsAsync(helpers.getServer({94    preformatter: {}95  }))96  await t.throwsAsync(helpers.getServer({97    preformatter: []98  }))99  await t.throwsAsync(helpers.getServer({100    preformatter: new RegExp()101  }))102})103test('throw error if own options are invalid – postformatter', async (t) => {104  await t.throwsAsync(helpers.getServer({105    postformatter: (a, b, c) => ({ a, b, c })106  }))107  await t.throwsAsync(helpers.getServer({108    postformatter: null109  }))110  await t.throwsAsync(helpers.getServer({111    postformatter: false112  }))113  await t.throwsAsync(helpers.getServer({114    postformatter: NaN115  }))116  await t.throwsAsync(helpers.getServer({117    postformatter: {}118  }))119  await t.throwsAsync(helpers.getServer({120    postformatter: []121  }))122  await t.throwsAsync(helpers.getServer({123    postformatter: new RegExp()124  }))125})126test('throw error if own options are invalid – handleUncaught', async (t) => {127  await t.throwsAsync(helpers.getServer({128    handleUncaught: null129  }))130  await t.throwsAsync(helpers.getServer({131    handleUncaught: 42132  }))133  await t.throwsAsync(helpers.getServer({134    handleUncaught: ''135  }))136  await t.throwsAsync(helpers.getServer({137    handleUncaught: 'foobar'138  }))139  await t.throwsAsync(helpers.getServer({140    handleUncaught: NaN141  }))142  await t.throwsAsync(helpers.getServer({143    handleUncaught: {}144  }))145  await t.throwsAsync(helpers.getServer({146    handleUncaught: []147  }))148  await t.throwsAsync(helpers.getServer({149    handleUncaught: new RegExp()150  }))151})152test('throw no error if own options are valid – default', async (t) => {153  await t.notThrowsAsync(helpers.getServer({}))154})155test('throw no error if own options are valid – default/root ', async (t) => {156  await t.notThrowsAsync(helpers.getServer({}, true))157})158test('throw no error if own options are valid – colored', async (t) => {159  await t.notThrowsAsync(helpers.getServer({160    colored: true161  }))162})163test('throw no error if own options are valid – override', async (t) => {164  await t.notThrowsAsync(helpers.getServer({165    override: true166  }))167})168test('throw no error if own options are valid – indent', async (t) => {169  await t.notThrowsAsync(helpers.getServer({170    indent: 4171  }))172  await t.notThrowsAsync(helpers.getServer({173    indent: ''174  }))175  await t.notThrowsAsync(helpers.getServer({176    indent: '  '177  }))178})179test('throw no error if own options are valid – handleUncaught', async (t) => {180  await t.notThrowsAsync(helpers.getServer({181    handleUncaught: true182  }))183  await t.notThrowsAsync(helpers.getServer({184    handleUncaught: false185  }))186})187test('throw no error if own options are valid – preformatter', async (t) => {188  await t.notThrowsAsync(helpers.getServer({189    preformatter: () => ({ foo: 'bar' })190  }))191  await t.notThrowsAsync(helpers.getServer({192    preformatter: (a) => (a)193  }))194  await t.notThrowsAsync(helpers.getServer({195    preformatter: (a, b) => ({ a, b })196  }))197})198test('throw no error if own options are valid – postformatter', async (t) => {199  await t.notThrowsAsync(helpers.getServer({200    preformatter: () => ('foobar')201  }))202  await t.notThrowsAsync(helpers.getServer({203    preformatter: (a) => (a)204  }))205  await t.notThrowsAsync(helpers.getServer({206    postformatter: (a, b) => ({ a, b })207  }))...

Full Screen

Full Screen

http.test.js

Source:http.test.js Github

copy

Full Screen

...7        app.loadHttpMiddlewares();8    });9    describe('http request', function () {10        it('call http should response 200', function (done) {11            request(app.getServer())12                .get('/home/index/index')13                .expect(200)14                .expect('Hello World!')15                .end(done);16        });17        it('call http should response 200', function (done) {18            koahub.config('url_suffix', '.html');19            request(app.getServer())20                .get('/home/index/index.html')21                .expect(200)22                .expect('Hello World!')23                .end(done);24        })25        it('call http should response 404', function (done) {26            koahub.config('url_suffix', '.html');27            request(app.getServer())28                .get('/home/index/index.php')29                .expect(404)30                .end(done);31        })32        it('call http should response 404', function (done) {33            koahub.config('url_suffix', '');34            request(app.getServer())35                .get('/home/index/index.jpg')36                .expect(404)37                .end(done);38        })39        it('call http // should response 404', function (done) {40            request(app.getServer())41                .get('//')42                .expect(404)43                .end(done);44        })45        it('call /home/index/index2 should response 200', function (done) {46            request(app.getServer())47                .get('/home/index/index2')48                .expect(200)49                .expect('Hello World!')50                .end(done);51        });52        it('call /home/index/index4 should response 200', function (done) {53            request(app.getServer())54                .get('/home/index/index4')55                .expect(200)56                .expect('3')57                .end(done);58        });59        it('call http should response 200 body Hello World!', function (done) {60            request(app.getServer())61                .get('/home/index/index')62                .expect('Hello World!')63                .end(done);64        });65        it('call /admin should response 404', function (done) {66            request(app.getServer())67                .get('/admin')68                .expect(404)69                .end(done);70        });71        it('call /app/notfound should response 404', function (done) {72            request(app.getServer())73                .get('/app/notfound')74                .expect(404)75                .end(done);76        });77        it('call /home/index/notfound should response 404', function (done) {78            request(app.getServer())79                .get('/home/index/notfound')80                .expect(404)81                .end(done);82        });83        it('call /home/index/index5 should response 200', function (done) {84            request(app.getServer())85                .get('/home/index/index5')86                .expect(200)87                .end(done);88        });89        it('call /home/index/index6 should response 200', function (done) {90            request(app.getServer())91                .get('/home/index/index6')92                .expect(200)93                .expect('1')94                .end(done);95        });96        it('call /home/index/message should response 500', function (done) {97            request(app.getServer())98                .get('/home/index/message')99                .expect(500)100                .end(done);101        });102        it('call /home/shop/index should response 200', function (done) {103            request(app.getServer())104                .get('/home/shop/index')105                .expect(200)106                .end(done);107        });108        it('call /index/index should response 404', function (done) {109            request(app.getServer())110                .get('/index/index')111                .expect(404)112                .end(done);113        });114        it('call /home/index/_before should response 404', function (done) {115            request(app.getServer())116                .get('/home/index/_before')117                .expect(404)118                .end(done);119        });120        it('call /home/notfound/index should response 200', function (done) {121            request(app.getServer())122                .get('/home/notfound/index')123                .expect(200)124                .end(done);125        });126    });127    describe('router request', function () {128        it('call /product should 200 body Hello World!', function (done) {129            request(app.getServer())130                .get('/product')131                .expect(200)132                .expect('Hello World!')133                .end(done);134        });135        it('call get /product/1 should 200 body 1', function (done) {136            request(app.getServer())137                .get('/product/1')138                .expect(200)139                .expect('1')140                .end(done);141        });142        it('call post /product/1 should 404', function (done) {143            request(app.getServer())144                .post('/product/1')145                .expect(404)146                .end(done);147        });148        it('call post /product should 404', function (done) {149            delete koahub.configs.router;150            request(app.getServer())151                .post('/product')152                .expect(404)153                .end(done);154        });155    });...

Full Screen

Full Screen

method.test.js

Source:method.test.js Github

copy

Full Screen

...9        beforeEach(function () {10            app.loadHttpMiddlewares();11        });12        it('call get /home/method/is_get should response 200', function (done) {13            request(app.getServer())14                .get('/home/method/is_get')15                .expect(200)16                .expect('true')17                .end(done);18        });19        it('call post /home/method/is_get should response false', function (done) {20            request(app.getServer())21                .post('/home/method/is_get')22                .expect(200)23                .expect('false')24                .end(done);25        });26        it('call get /home/method/is_post should response 200', function (done) {27            request(app.getServer())28                .get('/home/method/is_post')29                .expect(200)30                .expect('false')31                .end(done);32        });33        it('call get /home/method/is_post should response 200', function (done) {34            request(app.getServer())35                .post('/home/method/is_post')36                .expect(200)37                .expect('true')38                .end(done);39        });40        it('call post /home/method/is_post_id should response 200', function (done) {41            request(app.getServer())42                .post('/home/method/is_post_id')43                .field('id', '1')44                .expect(200)45                .expect('1')46                .end(done);47        });48        it('call header /home/method/is_ajax should response 200', function (done) {49            request(app.getServer())50                .get('/home/method/is_ajax')51                .set('X-Requested-With', 'XMLHttpRequest')52                .expect(200)53                .expect('true')54                .end(done);55        });56        it('call header /home/method/is_pjax should response 200', function (done) {57            request(app.getServer())58                .get('/home/method/is_pjax')59                .set('X-PJAX', 'true')60                .expect(200)61                .expect('true')62                .end(done);63        });64        it('call get /home/method/is_pjax should response false', function (done) {65            request(app.getServer())66                .get('/home/method/is_pjax')67                .expect(200)68                .expect('false')69                .end(done);70        });71        it('call get /home/method/is_method should response true', function (done) {72            request(app.getServer())73                .get('/home/method/is_method')74                .expect(200)75                .expect('true')76                .end(done);77        });78        it('call get /home/method/json_body should response {data: 1}', function (done) {79            request(app.getServer())80                .get('/home/method/json_body')81                .expect(200)82                .expect({data: 1})83                .end(done);84        });85        it('call get /home/method/json_body_msg should response {data: 1, msg: 2}', function (done) {86            request(app.getServer())87                .get('/home/method/json_body_msg')88                .expect(200)89                .expect({data: 1, msg: 2})90                .end(done);91        });92        it('call get /home/method/json_body_msg_code should response {data: 1, msg: 2, code: 3}', function (done) {93            request(app.getServer())94                .get('/home/method/json_body_msg_code')95                .expect(200)96                .expect({data: 1, msg: 2, code: 3})97                .end(done);98        });99        it('call get /home/method/json_success should response {data: 1, msg: 2, code: 1}', function (done) {100            request(app.getServer())101                .get('/home/method/json_success')102                .expect(200)103                .expect({data: 1, msg: 2, code: 1})104                .end(done);105        });106        it('call get /home/method/json_error should response {data: 1, msg: 2, code: 0}', function (done) {107            request(app.getServer())108                .get('/home/method/json_error')109                .expect(200)110                .expect({data: 1, msg: 2, code: 0})111                .end(done);112        });113        it('call get /home/method/download_file should response file.zip', function (done) {114            request(app.getServer())115                .get('/home/method/download_file')116                .expect(200)117                .end(done);118        });119    });120    describe('ctx method test', function () {121        beforeEach(function () {122            app.use(function (ctx, next) {123                ctx.render = function *(a, b) {124                    return a + b;125                }126                return next();127            });128            app.loadHttpMiddlewares();129        });130        it('call get / should response 3', function (done) {131            request(app.getServer())132                .get('/home/method/gen')133                .expect(200)134                .expect('3')135                .end(done);136        });137    });...

Full Screen

Full Screen

GetURL.js

Source:GetURL.js Github

copy

Full Screen

...39  const region = akinatorRegion.toLowerCase();40  switch (region) {41    case 'en':42    case 'english':43      return getServer('en');44    case 'en_objects':45    case 'english_objects':46      return getServer('en_objects');47    case 'en_animals':48    case 'english_animals':49      return getServer('en_animals');50    case 'ar':51    case 'arabic':52      return getServer('ar');53    case 'cn':54    case 'chinese':55      return getServer('cn');56    case 'de':57    case 'german':58      return getServer('de');59    case 'de_animals':60    case 'german_animals':61      return getServer('de_animals');62    case 'es':63    case 'spanish':64      return getServer('es');65    case 'es_animals':66    case 'spanish_animals':67      return getServer('es_animals');68    case 'fr':69    case 'french':70      return getServer('fr');71    case 'fr_objects':72    case 'french_objects':73      return getServer('fr_objects');74    case 'fr_animals':75    case 'french_animals':76      return getServer('fr_animals');77    case 'il':78    case 'hebrew':79      return getServer('il');80    case 'it':81    case 'italian':82      return getServer('it');83    case 'it_animals':84    case 'italian_animals':85      return getServer('it_animals');86    case 'jp':87    case 'japanese':88      return getServer('jp');89    case 'jp_animals':90    case 'japanese_animals':91      return getServer('jp_animals');92    case 'kr':93    case 'korean':94      return getServer('kr');95    case 'nl':96    case 'dutch':97      return getServer('nl');98    case 'pl':99    case 'polish':100      return getServer('pl');101    case 'pt':102    case 'portuguese':103      return getServer('pt');104    case 'ru':105    case 'russian':106      return getServer('ru');107    case 'tr':108    case 'turkish':109      return getServer('tr');110    case 'id':111    case 'indonesia':112      return getServer('id');113    default:114      return region ? getServer(region) : getServer('en');115  }116};...

Full Screen

Full Screen

tatva-apps-api.js

Source:tatva-apps-api.js Github

copy

Full Screen

1var server = "http://tatvainc.dyndns-ip.com/tapi";2function getServer() {3	return server; 4}5function setServer( serverString ) {6	server = serverString;7	//alert('Server is: '+ getServer());8}9function gmailAuthentication(username, password, userCallBack) {10    url = getServer() + '/webapi%20credentials?username='+username+'&password='+password+'&'+'register=0';11    ajaxLoad(userCallBack, url);12}13function syncAmwayDB(username, password, callBack) {14    url = getServer() + '/webapi%20syncAmwayDB?username='+username+'&password='+password;15    ajaxLoad(callBack, url);16    17}18function loadDB(iboNum, callBack) {19    url = getServer() + '/webapi%20userdb?username='+iboNum;20    ajaxLoad(callBack, url);21}22function loadLos(iboNum, callBack) {23    url = getServer() + '/webapi%20getlos?username='+iboNum;24    ajaxLoad(callBack, url);25}26var pos = null;27function showPosition(position) {28 	pos = position; 29}30function getLocation() {31	pos = navigator.geolocation.getCurrentPosition(showPosition); 32}33function getbsmcatalog(callBack) {34    url = getServer() + '/webapi%20getbsmcatalog';35    ajaxLoad(callBack, url);36}37function uploadContact(contactObj, callBack) {38    c = contactObj;39    url = getServer() + '/webapi%20loadcontact?ibonumber='+c.ibonumber+"&firstname="+c.firstname+ 40	  "&lastname="+c.lastname+"&phone="+c.phone+"&email="+c.email+"&location="+position.coords.latitude+41	  ";"+position.coords.longitude;42    ajaxLoad(callBack, url);43}44	45function loadVolume(ibonumber, callBack) {46    url = getServer() + '/webapi%20getlatestvolume?ibonumber='+ibonumber; 47    ajaxLoad(callBack, url);48}49function loadVolumeSeries(ibonumber,yymm, callBack) {50    url = getServer() + '/webapi%20getvolumeseries?ibonumber='+ibonumber+'&yymm='+yymm; 51    ajaxLoad(callBack, url);52}53function loadPersonalVolume(ibonumber,yymm, callBack) {54    url = getServer() + '/webapi%20getpersonalvolumeseries?ibonumber='+ibonumber+'&yymm='+yymm; 55    ajaxLoad(callBack, url);56}57function updateCoreSteps(iboNumber, books, cds, plan, productuse, client, teach, integrity, association, tech, callBack) {58	/*coresteps.put("books", "1");59		coresteps.put("cds", "0");60		coresteps.put("plan", "0");61		coresteps.put("productuse", "1");62		coresteps.put("client", "1");63		coresteps.put("teach", "1");64		coresteps.put("integrity", "1");65		coresteps.put("association", "1");66		coresteps.put("tech", "1");*/67    core = JSON.parse(coreObj);68    url = getServer() + '/webapi%20updatecoresteps='+ibonumber+'&books='+books+'&cds='+cds+ '&plan='+ plan+'&productuse='+productuse+'&client='+client+'&teach='+teach+'&integrity='+integrity+'&association='+association+'&tech='+tech; 69    ajaxLoad(callBack, url);70}71function sendSmsForm() {72	phone   = document.getElementById('phone').value;73	message = document.getElementById('message').value;74	sendSms(phone,message);75}76function sendSms(phone, message) {77	url = getServer()+ '/webapi%20sendsms?phone='+phone+'&message='+message;78	ajaxLoad(smsCallBack, url);79} 80function smsCallBack(response) {81	//alert(response);82}...

Full Screen

Full Screen

services.js

Source:services.js Github

copy

Full Screen

1import request from '../../utils/request';2import Configure from '../../common/configure';3export async function logout(params) {4  return request(Configure.getServer('logout.cgi'), {5    method: 'POST',6    body: params,7  });8}9export async function queryUser(params) {10  return request(Configure.getServer('getUser.cgi'), {11    method: 'POST',12    body: params,13  });14}15export async function fetchMenus(params) {16  return request(Configure.getServer('fetchMenus.cgi'), {17    method: 'POST',18    body: params,19  });20}21export async function userAdd(params) {22  return request(Configure.getServer('users/userAdd.cgi'), {23    method: 'POST',24    body: params,25  });26}27export async function userList(params) {28  return request(Configure.getServer('users/userList.cgi'), {29    method: 'POST',30    body: params,31  });32}33export async function userUpdate(params) {34  return request(Configure.getServer('users/userUpdate.cgi'), {35    method: 'POST',36    body: params,37  });38}39export async function userDelete(params) {40  return request(Configure.getServer('users/userDelete.cgi'), {41    method: 'POST',42    body: params,43  });44}45export async function userDetail(params) {46  return request(Configure.getServer('users/userDetail.cgi'), {47    method: 'POST',48    body: params,49  });50}51export async function allRole(params) {52  return request(Configure.getServer('users/allRole.cgi'), {53    method: 'POST',54    body: params,55  });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3    capabilities: {4    }5};6const client = wdio.remote(opts);7    .init()8    .then(() => client.getServer())9    .then((server) => console.log(server))10    .then(() => client.end());

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3    desiredCapabilities: {4    }5};6(async function myFunction() {7    let client = await wdio.remote(opts);8    let url = await client.getServer();9    console.log(url);10    await client.deleteSession();11})();12const wdio = require('webdriverio');13const opts = {14    desiredCapabilities: {15    }16};17(async function myFunction() {18    let client = await wdio.remote(opts);19    let session = await client.getSessions();20    console.log(session);21    await client.deleteSession();22})();23  {24    capabilities: {25    }26  }

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const assert = require('assert');3describe('Test Appium XCUITest Driver', function() {4    this.timeout(60000);5    let driver;6    before(async function() {7        driver = await wdio.remote({8            capabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var xcu = require('appium-xcuitest-driver');2var xcuDriver = new xcu.XCUITestDriver();3var server = xcuDriver.getServer();4xcuDriver.setServer(server);5var xcu = require('appium-xcuitest-driver');6var xcuDriver = new xcu.XCUITestDriver();7var server = xcuDriver.getServer();8xcuDriver.setServer(server);9var xcu = require('appium-xcuitest-driver');10var xcuDriver = new xcu.XCUITestDriver();11var server = xcuDriver.getServer();12xcuDriver.setServer(server);

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 Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful