@@ -23,6 +23,8 @@ const mockConnections: ConnectionInfo[] = [
23
23
metricsId : 'metricsId' ,
24
24
metricsType : 'host' ,
25
25
instanceSize : 'M10' ,
26
+ clusterType : 'REPLICASET' ,
27
+ clusterUniqueId : 'clusterUniqueId' ,
26
28
} ,
27
29
} ,
28
30
{
@@ -38,6 +40,8 @@ const mockConnections: ConnectionInfo[] = [
38
40
metricsId : 'metricsId' ,
39
41
metricsType : 'replicaSet' ,
40
42
instanceSize : 'M0' ,
43
+ clusterType : 'REPLICASET' ,
44
+ clusterUniqueId : 'clusterUniqueId' ,
41
45
} ,
42
46
} ,
43
47
{
@@ -53,6 +57,8 @@ const mockConnections: ConnectionInfo[] = [
53
57
metricsId : 'metricsId' ,
54
58
metricsType : 'serverless' ,
55
59
instanceSize : 'SERVERLESS_V2' ,
60
+ clusterType : 'REPLICASET' ,
61
+ clusterUniqueId : 'clusterUniqueId' ,
56
62
} ,
57
63
} ,
58
64
{
@@ -68,6 +74,8 @@ const mockConnections: ConnectionInfo[] = [
68
74
metricsId : 'metricsId' ,
69
75
metricsType : 'replicaSet' ,
70
76
instanceSize : 'M10' ,
77
+ clusterType : 'REPLICASET' ,
78
+ clusterUniqueId : 'clusterUniqueId' ,
71
79
} ,
72
80
} ,
73
81
{
@@ -83,79 +91,132 @@ const mockConnections: ConnectionInfo[] = [
83
91
metricsId : 'metricsId' ,
84
92
metricsType : 'cluster' ,
85
93
instanceSize : 'M10' ,
94
+ clusterType : 'SHARDED' ,
95
+ clusterUniqueId : 'clusterUniqueId' ,
96
+ } ,
97
+ } ,
98
+ {
99
+ id : 'dedicated-geo-sharded' ,
100
+ connectionOptions : {
101
+ connectionString : 'mongodb://foo' ,
102
+ } ,
103
+ atlasMetadata : {
104
+ orgId : 'orgId' ,
105
+ projectId : 'projectId' ,
106
+ clusterName : 'clusterName' ,
107
+ regionalBaseUrl : 'https://example.com' ,
108
+ metricsId : 'metricsId' ,
109
+ metricsType : 'cluster' ,
110
+ instanceSize : 'M30' ,
111
+ clusterType : 'GEOSHARDED' ,
112
+ clusterUniqueId : 'clusterUniqueId' ,
86
113
} ,
87
114
} ,
88
115
] ;
89
116
90
117
describe ( 'useConnectionSupports' , function ( ) {
91
- it ( 'should return false if the connection does not exist' , function ( ) {
92
- const { result } = renderHookWithConnections (
93
- ( ) => useConnectionSupports ( 'does-not-exist' , 'rollingIndexCreation' ) ,
94
- {
95
- connections : mockConnections ,
96
- }
97
- ) ;
98
- expect ( result . current ) . to . equal ( false ) ;
99
- } ) ;
118
+ context ( 'rollingIndexCreation' , function ( ) {
119
+ it ( 'should return false if the connection does not exist' , function ( ) {
120
+ const { result } = renderHookWithConnections (
121
+ ( ) => useConnectionSupports ( 'does-not-exist' , 'rollingIndexCreation' ) ,
122
+ {
123
+ connections : mockConnections ,
124
+ }
125
+ ) ;
126
+ expect ( result . current ) . to . equal ( false ) ;
127
+ } ) ;
100
128
101
- it ( 'should return false if the connection has no atlasMetadata' , function ( ) {
102
- const { result } = renderHookWithConnections (
103
- ( ) => useConnectionSupports ( 'no-atlasMetadata' , 'rollingIndexCreation' ) ,
104
- {
105
- connections : mockConnections ,
106
- }
107
- ) ;
108
- expect ( result . current ) . to . equal ( false ) ;
109
- } ) ;
129
+ it ( 'should return false if the connection has no atlasMetadata' , function ( ) {
130
+ const { result } = renderHookWithConnections (
131
+ ( ) => useConnectionSupports ( 'no-atlasMetadata' , 'rollingIndexCreation' ) ,
132
+ {
133
+ connections : mockConnections ,
134
+ }
135
+ ) ;
136
+ expect ( result . current ) . to . equal ( false ) ;
137
+ } ) ;
110
138
111
- it ( 'should return false for host cluster type' , function ( ) {
112
- const { result } = renderHookWithConnections (
113
- ( ) => useConnectionSupports ( 'host-cluster' , 'rollingIndexCreation' ) ,
114
- {
115
- connections : mockConnections ,
116
- }
117
- ) ;
118
- expect ( result . current ) . to . equal ( false ) ;
119
- } ) ;
139
+ it ( 'should return false for host cluster type' , function ( ) {
140
+ const { result } = renderHookWithConnections (
141
+ ( ) => useConnectionSupports ( 'host-cluster' , 'rollingIndexCreation' ) ,
142
+ {
143
+ connections : mockConnections ,
144
+ }
145
+ ) ;
146
+ expect ( result . current ) . to . equal ( false ) ;
147
+ } ) ;
120
148
121
- it ( 'should return false for serverless cluster type' , function ( ) {
122
- const { result } = renderHookWithConnections (
123
- ( ) => useConnectionSupports ( 'serverless-cluster' , 'rollingIndexCreation' ) ,
124
- {
125
- connections : mockConnections ,
126
- }
127
- ) ;
128
- expect ( result . current ) . to . equal ( false ) ;
129
- } ) ;
149
+ it ( 'should return false for serverless cluster type' , function ( ) {
150
+ const { result } = renderHookWithConnections (
151
+ ( ) =>
152
+ useConnectionSupports ( 'serverless-cluster' , 'rollingIndexCreation' ) ,
153
+ {
154
+ connections : mockConnections ,
155
+ }
156
+ ) ;
157
+ expect ( result . current ) . to . equal ( false ) ;
158
+ } ) ;
130
159
131
- it ( 'should return false for free/shared tier clusters' , function ( ) {
132
- const { result } = renderHookWithConnections (
133
- ( ) => useConnectionSupports ( 'free-cluster' , 'rollingIndexCreation' ) ,
134
- {
135
- connections : mockConnections ,
136
- }
137
- ) ;
138
- expect ( result . current ) . to . equal ( false ) ;
139
- } ) ;
160
+ it ( 'should return false for free/shared tier clusters' , function ( ) {
161
+ const { result } = renderHookWithConnections (
162
+ ( ) => useConnectionSupports ( 'free-cluster' , 'rollingIndexCreation' ) ,
163
+ {
164
+ connections : mockConnections ,
165
+ }
166
+ ) ;
167
+ expect ( result . current ) . to . equal ( false ) ;
168
+ } ) ;
169
+
170
+ it ( 'should return true for dedicated replicaSet clusters' , function ( ) {
171
+ const { result } = renderHookWithConnections (
172
+ ( ) =>
173
+ useConnectionSupports ( 'dedicated-replicaSet' , 'rollingIndexCreation' ) ,
174
+ {
175
+ connections : mockConnections ,
176
+ }
177
+ ) ;
178
+ expect ( result . current ) . to . equal ( true ) ;
179
+ } ) ;
140
180
141
- it ( 'should return true for dedicated replicaSet clusters' , function ( ) {
142
- const { result } = renderHookWithConnections (
143
- ( ) =>
144
- useConnectionSupports ( 'dedicated-replicaSet' , 'rollingIndexCreation' ) ,
145
- {
146
- connections : mockConnections ,
147
- }
148
- ) ;
149
- expect ( result . current ) . to . equal ( true ) ;
181
+ it ( 'should return true for dedicated sharded clusters' , function ( ) {
182
+ const { result } = renderHookWithConnections (
183
+ ( ) =>
184
+ useConnectionSupports ( 'dedicated-sharded' , 'rollingIndexCreation' ) ,
185
+ {
186
+ connections : mockConnections ,
187
+ }
188
+ ) ;
189
+ expect ( result . current ) . to . equal ( true ) ;
190
+ } ) ;
150
191
} ) ;
192
+ context ( 'globalWrites' , function ( ) {
193
+ it ( 'should return false if the connection does not exist' , function ( ) {
194
+ const { result } = renderHookWithConnections (
195
+ ( ) => useConnectionSupports ( 'does-not-exist' , 'globalWrites' ) ,
196
+ {
197
+ connections : mockConnections ,
198
+ }
199
+ ) ;
200
+ expect ( result . current ) . to . equal ( false ) ;
201
+ } ) ;
202
+ it ( 'should return false if the connection has no atlasMetadata' , function ( ) {
203
+ const { result } = renderHookWithConnections (
204
+ ( ) => useConnectionSupports ( 'no-atlasMetadata' , 'globalWrites' ) ,
205
+ {
206
+ connections : mockConnections ,
207
+ }
208
+ ) ;
209
+ expect ( result . current ) . to . equal ( false ) ;
210
+ } ) ;
151
211
152
- it ( 'should return true for dedicated sharded clusters' , function ( ) {
153
- const { result } = renderHookWithConnections (
154
- ( ) => useConnectionSupports ( 'dedicated-sharded' , 'rollingIndexCreation' ) ,
155
- {
156
- connections : mockConnections ,
157
- }
158
- ) ;
159
- expect ( result . current ) . to . equal ( true ) ;
212
+ it ( 'should return true if the cluster type is geosharded' , function ( ) {
213
+ const { result } = renderHookWithConnections (
214
+ ( ) => useConnectionSupports ( 'dedicated-geo-sharded' , 'globalWrites' ) ,
215
+ {
216
+ connections : mockConnections ,
217
+ }
218
+ ) ;
219
+ expect ( result . current ) . to . equal ( true ) ;
220
+ } ) ;
160
221
} ) ;
161
222
} ) ;
0 commit comments