1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
1
18
import { expect } from 'chai' ;
2
- import { TransportOptions , areTransportOptionsEqual , connectDataConnectEmulator , getDataConnect } from '../../src/api/DataConnect' ;
19
+ import {
20
+ TransportOptions ,
21
+ areTransportOptionsEqual ,
22
+ connectDataConnectEmulator ,
23
+ getDataConnect
24
+ } from '../../src/api/DataConnect' ;
3
25
import { app } from '../util' ;
4
26
import { queryRef } from '../../src' ;
5
27
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 ) ;
28
+ it ( 'should return false if transport options are not equal' , ( ) => {
29
+ const transportOptions1 : TransportOptions = {
30
+ host : 'h' ,
31
+ port : 1 ,
32
+ sslEnabled : false
33
+ } ;
34
+ const transportOptions2 : TransportOptions = {
35
+ host : 'h2' ,
36
+ port : 2 ,
37
+ sslEnabled : false
38
+ } ;
39
+ expect (
40
+ areTransportOptionsEqual ( transportOptions1 , transportOptions2 )
41
+ ) . to . eq ( false ) ;
42
+ } ) ;
43
+ it ( 'should return true if transport options are equal' , ( ) => {
44
+ const transportOptions1 : TransportOptions = {
45
+ host : 'h' ,
46
+ port : 1 ,
47
+ sslEnabled : false
48
+ } ;
49
+ const transportOptions2 : TransportOptions = {
50
+ host : 'h' ,
51
+ port : 1 ,
52
+ sslEnabled : false
53
+ } ;
54
+ expect (
55
+ areTransportOptionsEqual ( transportOptions1 , transportOptions2 )
56
+ ) . to . eq ( true ) ;
57
+ } ) ;
58
+ it . only ( 'should throw if emulator is connected to with new transport options' , ( ) => {
59
+ const dc = getDataConnect ( app , {
60
+ connector : 'c' ,
61
+ location : 'l' ,
62
+ service : 's'
18
63
} ) ;
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 ) ;
64
+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h' , 80 , false ) ) . to . not . throw ( ) ;
65
+ queryRef ( dc , 'query' ) ;
66
+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h2' , 80 , false ) ) . to . throw (
67
+ 'DataConnect instance already initialized!'
68
+ ) ;
69
+ } ) ;
70
+ it . only ( 'should not throw if emulator is connected to with the same transport options' , ( ) => {
71
+ const dc = getDataConnect ( app , {
72
+ connector : 'c' ,
73
+ location : 'l' ,
74
+ service : 's'
31
75
} ) ;
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
- } ) ;
76
+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h' , 80 , false ) ) . to . not . throw ( ) ;
77
+ queryRef ( dc , 'query' ) ;
78
+ expect ( ( ) => connectDataConnectEmulator ( dc , 'h' , 80 , false ) ) . to . not . throw ( ) ;
79
+ } ) ;
80
+ } ) ;
0 commit comments