@@ -151,29 +151,7 @@ describe("Session", () => {
151151 connectionString : "mongodb://localhost:27017" ,
152152 } ) ;
153153
154- expect ( await session . isSearchAvailable ( ) ) . toEqual ( "available" ) ;
155- } ) ;
156-
157- it ( "should return 'available' if listing search indexes succeed and we don't have write permissions" , async ( ) => {
158- getSearchIndexesMock . mockResolvedValue ( [ ] ) ;
159- insertOneMock . mockRejectedValue ( new Error ( "Read only mode" ) ) ;
160- createSearchIndexesMock . mockResolvedValue ( [ ] ) ;
161-
162- await session . connectToMongoDB ( {
163- connectionString : "mongodb://localhost:27017" ,
164- } ) ;
165-
166- expect ( await session . isSearchAvailable ( ) ) . toEqual ( "available" ) ;
167- } ) ;
168-
169- it ( "should return 'not-available-yet' if listing search indexes work but can not create an index" , async ( ) => {
170- getSearchIndexesMock . mockResolvedValue ( [ ] ) ;
171- insertOneMock . mockResolvedValue ( [ ] ) ;
172- createSearchIndexesMock . mockRejectedValue ( new Error ( "SearchNotAvailable" ) ) ;
173- await session . connectToMongoDB ( {
174- connectionString : "mongodb://localhost:27017" ,
175- } ) ;
176- expect ( await session . isSearchAvailable ( ) ) . toEqual ( "not-available-yet" ) ;
154+ expect ( await session . isSearchSupported ( ) ) . toBeTruthy ( ) ;
177155 } ) ;
178156
179157 it ( "should return false if listing search indexes fail with search error" , async ( ) => {
@@ -182,51 +160,29 @@ describe("Session", () => {
182160 await session . connectToMongoDB ( {
183161 connectionString : "mongodb://localhost:27017" ,
184162 } ) ;
185- expect ( await session . isSearchAvailable ( ) ) . toEqual ( false ) ;
163+ expect ( await session . isSearchSupported ( ) ) . toEqual ( false ) ;
186164 } ) ;
187165 } ) ;
188166
189- describe ( "assertSearchAvailable " , ( ) => {
167+ describe ( "assertSearchSupported " , ( ) => {
190168 let getSearchIndexesMock : MockedFunction < ( ) => unknown > ;
191- let createSearchIndexesMock : MockedFunction < ( ) => unknown > ;
192169
193170 beforeEach ( ( ) => {
194171 getSearchIndexesMock = vi . fn ( ) ;
195- createSearchIndexesMock = vi . fn ( ) ;
196172
197173 MockNodeDriverServiceProvider . connect = vi . fn ( ) . mockResolvedValue ( {
198174 getSearchIndexes : getSearchIndexesMock ,
199- createSearchIndexes : createSearchIndexesMock ,
200- insertOne : vi . fn ( ) . mockResolvedValue ( { } ) ,
201- dropDatabase : vi . fn ( ) . mockResolvedValue ( { } ) ,
202175 } as unknown as NodeDriverServiceProvider ) ;
203176 } ) ;
204177
205178 it ( "should not throw if it is available" , async ( ) => {
206179 getSearchIndexesMock . mockResolvedValue ( [ ] ) ;
207- createSearchIndexesMock . mockResolvedValue ( [ ] ) ;
208-
209- await session . connectToMongoDB ( {
210- connectionString : "mongodb://localhost:27017" ,
211- } ) ;
212-
213- await expect ( session . assertSearchAvailable ( ) ) . resolves . not . toThrowError ( ) ;
214- } ) ;
215-
216- it ( "should throw if it is supported but not available" , async ( ) => {
217- getSearchIndexesMock . mockResolvedValue ( [ ] ) ;
218- createSearchIndexesMock . mockRejectedValue ( new Error ( "Not ready yet" ) ) ;
219180
220181 await session . connectToMongoDB ( {
221182 connectionString : "mongodb://localhost:27017" ,
222183 } ) ;
223184
224- await expect ( session . assertSearchAvailable ( ) ) . rejects . toThrowError (
225- new MongoDBError (
226- ErrorCodes . AtlasSearchNotAvailable ,
227- "Atlas Search is supported in the current cluster but not available yet."
228- )
229- ) ;
185+ await expect ( session . assertSearchSupported ( ) ) . resolves . not . toThrowError ( ) ;
230186 } ) ;
231187
232188 it ( "should throw if it is not supported" , async ( ) => {
@@ -236,7 +192,7 @@ describe("Session", () => {
236192 connectionString : "mongodb://localhost:27017" ,
237193 } ) ;
238194
239- await expect ( session . assertSearchAvailable ( ) ) . rejects . toThrowError (
195+ await expect ( session . assertSearchSupported ( ) ) . rejects . toThrowError (
240196 new MongoDBError (
241197 ErrorCodes . AtlasSearchNotSupported ,
242198 "Atlas Search is not supported in the current cluster."
0 commit comments