11'use strict' ;
2+
23var TbApi = require ( '../lib/api.js' ) ;
34var assert = require ( 'assert' ) ;
5+ var path = require ( 'path' ) ;
46
57describe ( 'Api Tests' , function ( ) {
68 beforeEach ( function ( done ) {
@@ -17,7 +19,7 @@ describe('Api Tests', function() {
1719 } ) ;
1820
1921 it ( 'should detect wrong credentials' , function ( done ) {
20- var api = new TbApi ( { api_key : 'bogus' , api_secret : 'bogus' } ) ;
22+ var api = new TbApi ( { api_key : 'bogus' , api_secret : 'bogus' } ) ;
2123 api . getUserInfo ( function ( err , response ) {
2224 assert . equal ( response , null ) ;
2325 assert . notEqual ( err , null ) ;
@@ -46,16 +48,16 @@ describe('Api Tests', function() {
4648 assert . equal ( response . data && response . data . length > 0 , true ) ;
4749 var singleTest = response . data [ 0 ] ;
4850 that . api . getTestDetails ( singleTest . id , function ( err , response ) {
49- assert . notEqual ( response , null ) ;
51+ assert . notEqual ( response , null ) ;
5052 done ( ) ;
5153 } ) ;
5254 } ) ;
5355 } ) ;
5456
5557 it ( 'should update a user object' , function ( done ) {
5658 var that = this ;
57- var newName = " name_" + Math . round ( Math . random ( ) * 10000 ) ;
58- this . api . updateUserInfo ( { user : { first_name : newName } } , function ( err , response ) {
59+ var newName = ' name_' + Math . round ( Math . random ( ) * 10000 ) ;
60+ this . api . updateUserInfo ( { user : { first_name : newName } } , function ( err , response ) {
5961 assert . equal ( err , null ) ;
6062 that . api . getUserInfo ( function ( err , response ) {
6163 assert . notEqual ( response , null ) ;
@@ -78,10 +80,10 @@ describe('Api Tests', function() {
7880 var singleTest = response . data [ 0 ] ;
7981 that . api . getTestDetails ( singleTest . id , function ( err , response ) {
8082 assert . notEqual ( response , null ) ;
81- var payload = { " test[success]" : "1" , " test[status_message]" : " test" } ;
83+ var payload = { ' test[success]' : '1' , ' test[status_message]' : ' test' } ;
8284 that . api . updateTest ( payload , singleTest . id , function ( err ) {
8385 that . api . getTestDetails ( singleTest . id , function ( err , response ) {
84- assert . equal ( response . status_message , " test" ) ;
86+ assert . equal ( response . status_message , ' test' ) ;
8587 done ( ) ;
8688 } ) ;
8789 } ) ;
@@ -96,10 +98,10 @@ describe('Api Tests', function() {
9698 var singleTest = response . data [ 0 ] ;
9799 that . api . getTestDetails ( singleTest . id , function ( err , response ) {
98100 assert . notEqual ( response , null ) ;
99- var payload = { test : { success : 1 , status_message : " test2" } } ;
101+ var payload = { test : { success : 1 , status_message : ' test2' } } ;
100102 that . api . updateTest ( payload , singleTest . id , function ( err ) {
101103 that . api . getTestDetails ( singleTest . id , function ( err , response ) {
102- assert . equal ( response . status_message , " test2" ) ;
104+ assert . equal ( response . status_message , ' test2' ) ;
103105 done ( ) ;
104106 } ) ;
105107 } ) ;
@@ -121,4 +123,19 @@ describe('Api Tests', function() {
121123 } ) ;
122124 } ) ;
123125 } ) ;
124- } ) ;
126+
127+ it ( 'should be possible to upload a local file' , function ( done ) {
128+ var testFilePath = path . resolve ( __dirname , 'test.apk' ) ;
129+ this . api . uploadFile ( testFilePath , function ( err , response ) {
130+ assert ( response . app_url !== undefined ) ;
131+ done ( ) ;
132+ } ) ;
133+ } ) ;
134+
135+ it ( 'should be possible to upload a remote file' , function ( done ) {
136+ this . api . uploadRemoteFile ( 'https://testingbot.com/appium/sample.apk' , function ( err , response ) {
137+ assert ( response . app_url !== undefined ) ;
138+ done ( ) ;
139+ } ) ;
140+ } ) ;
141+ } ) ;
0 commit comments