1+ import { expect } from 'chai' ;
2+ import { TransportOptions , areTransportOptionsEqual , connectDataConnectEmulator , getDataConnect } from '../../src/api/DataConnect' ;
3+ import { app } from '../util' ;
4+ import { queryRef } from '../../src' ;
5+ describe . only ( 'Transport Options' , ( ) => {
6+ it ( 'should return false if transport options are not equal' , ( ) => {
7+ const transportOptions1 : TransportOptions = {
8+ host : 'h' ,
9+ port : 1 ,
10+ sslEnabled : false
11+ } ;
12+ const transportOptions2 : TransportOptions = {
13+ host : 'h2' ,
14+ port : 2 ,
15+ sslEnabled : false
16+ } ;
17+ expect ( areTransportOptionsEqual ( transportOptions1 , transportOptions2 ) ) . to . eq ( false ) ;
18+ } ) ;
19+ it ( 'should return true if transport options are equal' , ( ) => {
20+ const transportOptions1 : TransportOptions = {
21+ host : 'h' ,
22+ port : 1 ,
23+ sslEnabled : false
24+ } ;
25+ const transportOptions2 : TransportOptions = {
26+ host : 'h' ,
27+ port : 1 ,
28+ sslEnabled : false
29+ } ;
30+ expect ( areTransportOptionsEqual ( transportOptions1 , transportOptions2 ) ) . to . eq ( true ) ;
31+ } ) ;
32+ it . only ( 'should throw if emulator is connected to with new transport options' , ( ) => {
33+ const dc = getDataConnect ( app , {
34+ connector : 'c' ,
35+ location : 'l' ,
36+ service : 's'
37+ } ) ;
38+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h' , 80 , false ) ) . to . not . throw ( ) ;
39+ queryRef ( dc , 'query' ) ;
40+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h2' , 80 , false ) ) . to . throw ( 'DataConnect instance already initialized!' ) ;
41+ } ) ;
42+ it . only ( 'should not throw if emulator is connected to with the same transport options' , ( ) => {
43+ const dc = getDataConnect ( app , {
44+ connector : 'c' ,
45+ location : 'l' ,
46+ service : 's'
47+ } ) ;
48+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h' , 80 , false ) ) . to . not . throw ( ) ;
49+ queryRef ( dc , 'query' ) ;
50+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h' , 80 , false ) ) . to . not . throw ( ) ;
51+ } ) ;
52+ } ) ;
0 commit comments