import { AdbClient } from '../lib/AdbClient' ; import { MockTransport } from './mock/MockTransport' ; import { MockKeyStore } from './mock/MockKeyStore' ; import { Options } from '../lib/Options' ; import { Crypto } from 'node-webcrypto-ossl' ; const crypto = new Crypto ( { directory : 'key_storage' } ) ; describe ( 'AdbClient' , ( ) => { const keyStore = new MockKeyStore ( ) ; const options = { debug : false , dump : false , useChecksum : false , keySize : 2048 , } as Options ; describe ( '#connect' , ( ) => { globalThis . btoa = ( input ) : string => { return Buffer . from ( input ) . toString ( 'base64' ) ; } ; globalThis . crypto = crypto ; let transport ; beforeEach ( ( ) => { transport = new MockTransport ( ) ; } ) ; it ( 'Server doesn\'t request AUTH and responds with CNXN' , async ( ) => { await transport . pushFromFile ( 'src/spec/data/messages/connect/connect_simple.json' ) ; const adbClient = new AdbClient ( transport , options , keyStore ) ; const adbDeviceInfo = await adbClient . connect ( ) ; expect ( adbDeviceInfo ) . toBeDefined ( ) ; } ) ; it ( 'Server responds with AUTH and then CNXN' , async ( ) => { await transport . pushFromFile ( 'src/spec/data/messages/connect/connect_auth_public_key.json' ) ; const adbClient = new AdbClient ( transport , options , keyStore ) ; const adbDeviceInfo = await adbClient . connect ( ) ; expect ( adbDeviceInfo ) . toBeDefined ( ) ; } ) ; } ) ; } ) ;