import { Connection } from "../src" ; test ( "example" , async ( ) => { const a = new Connection ( true , { stunServer : [ "stun.l.google.com" , 19302 ] , } ) ; const b = new Connection ( false , { stunServer : [ "stun.l.google.com" , 19302 ] , } ) ; await a . gatherCandidates ( ) ; b . remoteCandidates = a . localCandidates ; b . remoteUsername = a . localUserName ; b . remotePassword = a . localPassword ; await b . gatherCandidates ( ) ; a . remoteCandidates = b . localCandidates ; a . remoteUsername = b . localUserName ; a . remotePassword = b . localPassword ; await Promise . all ( [ a . connect ( ) , b . connect ( ) ] ) ; await a . send ( Buffer . from ( "howdee" ) ) ; let [ data ] = await b . onData . asPromise ( ) ; expect ( data . toString ( ) ) . toBe ( "howdee" ) ; await b . send ( Buffer . from ( "gotcha" ) ) ; [ data ] = await a . onData . asPromise ( ) ; expect ( data . toString ( ) ) . toBe ( "gotcha" ) ; await a . close ( ) ; await b . close ( ) ; } ) ;