@@ -386,8 +386,8 @@ describe('AtlasUserData', function () {
386386 context ( 'AtlasUserData.write' , function ( ) {
387387 it ( 'writes data successfully' , async function ( ) {
388388 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
389- getResourceUrlStub . resolves (
390- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
389+ getResourceUrlStub . returns (
390+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
391391 ) ;
392392
393393 const userData = getAtlasUserData ( ) ;
@@ -398,7 +398,7 @@ describe('AtlasUserData', function () {
398398
399399 const [ url , options ] = authenticatedFetchStub . firstCall . args ;
400400 expect ( url ) . to . equal (
401- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
401+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
402402 ) ;
403403 expect ( options . method ) . to . equal ( 'POST' ) ;
404404 expect ( options . headers [ 'Content-Type' ] ) . to . equal ( 'application/json' ) ;
@@ -417,8 +417,8 @@ describe('AtlasUserData', function () {
417417 authenticatedFetchStub . rejects (
418418 new Error ( 'HTTP 500: Internal Server Error' )
419419 ) ;
420- getResourceUrlStub . resolves (
421- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
420+ getResourceUrlStub . returns (
421+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
422422 ) ;
423423
424424 const userData = getAtlasUserData ( ) ;
@@ -429,8 +429,8 @@ describe('AtlasUserData', function () {
429429
430430 it ( 'validator removes unknown props' , async function ( ) {
431431 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
432- getResourceUrlStub . resolves (
433- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
432+ getResourceUrlStub . returns (
433+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
434434 ) ;
435435
436436 const userData = getAtlasUserData ( ) ;
@@ -445,8 +445,8 @@ describe('AtlasUserData', function () {
445445
446446 it ( 'uses custom serializer when provided' , async function ( ) {
447447 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
448- getResourceUrlStub . resolves (
449- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
448+ getResourceUrlStub . returns (
449+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
450450 ) ;
451451
452452 const userData = new AtlasUserData ( getTestSchema ( ) , 'FavoriteQueries' , {
@@ -469,8 +469,8 @@ describe('AtlasUserData', function () {
469469 context ( 'AtlasUserData.delete' , function ( ) {
470470 it ( 'deletes data successfully' , async function ( ) {
471471 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
472- getResourceUrlStub . resolves (
473- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
472+ getResourceUrlStub . returns (
473+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
474474 ) ;
475475
476476 const userData = getAtlasUserData ( ) ;
@@ -481,15 +481,15 @@ describe('AtlasUserData', function () {
481481
482482 const [ url , options ] = authenticatedFetchStub . firstCall . args ;
483483 expect ( url ) . to . equal (
484- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
484+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
485485 ) ;
486486 expect ( options . method ) . to . equal ( 'DELETE' ) ;
487487 } ) ;
488488
489489 it ( 'returns false when authenticatedFetch throws an error' , async function ( ) {
490490 authenticatedFetchStub . rejects ( new Error ( 'HTTP 404: Not Found' ) ) ;
491- getResourceUrlStub . resolves (
492- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
491+ getResourceUrlStub . returns (
492+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
493493 ) ;
494494
495495 const userData = getAtlasUserData ( ) ;
@@ -506,8 +506,8 @@ describe('AtlasUserData', function () {
506506 { data : JSON . stringify ( { name : 'Mongosh' } ) } ,
507507 ] ;
508508 authenticatedFetchStub . resolves ( mockResponse ( responseData ) ) ;
509- getResourceUrlStub . resolves (
510- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
509+ getResourceUrlStub . returns (
510+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
511511 ) ;
512512
513513 const userData = getAtlasUserData ( ) ;
@@ -535,15 +535,15 @@ describe('AtlasUserData', function () {
535535 expect ( authenticatedFetchStub ) . to . have . been . calledOnce ;
536536 const [ url , options ] = authenticatedFetchStub . firstCall . args ;
537537 expect ( url ) . to . equal (
538- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
538+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
539539 ) ;
540540 expect ( options . method ) . to . equal ( 'GET' ) ;
541541 } ) ;
542542
543543 it ( 'handles empty response' , async function ( ) {
544544 authenticatedFetchStub . resolves ( mockResponse ( [ ] ) ) ;
545- getResourceUrlStub . resolves (
546- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
545+ getResourceUrlStub . returns (
546+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
547547 ) ;
548548
549549 const userData = getAtlasUserData ( ) ;
@@ -555,8 +555,8 @@ describe('AtlasUserData', function () {
555555
556556 it ( 'handles non-array response' , async function ( ) {
557557 authenticatedFetchStub . resolves ( mockResponse ( { notAnArray : true } ) ) ;
558- getResourceUrlStub . resolves (
559- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
558+ getResourceUrlStub . returns (
559+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
560560 ) ;
561561
562562 const userData = getAtlasUserData ( ) ;
@@ -568,8 +568,8 @@ describe('AtlasUserData', function () {
568568
569569 it ( 'handles errors gracefully' , async function ( ) {
570570 authenticatedFetchStub . rejects ( new Error ( 'Unknown error' ) ) ;
571- getResourceUrlStub . resolves (
572- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
571+ getResourceUrlStub . returns (
572+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
573573 ) ;
574574
575575 const userData = getAtlasUserData ( ) ;
@@ -584,8 +584,8 @@ describe('AtlasUserData', function () {
584584 authenticatedFetchStub . rejects (
585585 new Error ( 'HTTP 500: Internal Server Error' )
586586 ) ;
587- getResourceUrlStub . resolves (
588- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
587+ getResourceUrlStub . returns (
588+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
589589 ) ;
590590
591591 const userData = getAtlasUserData ( ) ;
@@ -601,8 +601,8 @@ describe('AtlasUserData', function () {
601601 it ( 'uses custom deserializer when provided' , async function ( ) {
602602 const responseData = [ { data : 'custom:{"name":"Custom"}' } ] ;
603603 authenticatedFetchStub . resolves ( mockResponse ( responseData ) ) ;
604- getResourceUrlStub . resolves (
605- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
604+ getResourceUrlStub . returns (
605+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
606606 ) ;
607607
608608 const userData = new AtlasUserData ( getTestSchema ( ) , 'FavoriteQueries' , {
@@ -638,8 +638,8 @@ describe('AtlasUserData', function () {
638638 } ,
639639 ] ;
640640 authenticatedFetchStub . resolves ( mockResponse ( responseData ) ) ;
641- getResourceUrlStub . resolves (
642- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
641+ getResourceUrlStub . returns (
642+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
643643 ) ;
644644
645645 const userData = getAtlasUserData ( ) ;
@@ -670,12 +670,12 @@ describe('AtlasUserData', function () {
670670
671671 getResourceUrlStub
672672 . onFirstCall ( )
673- . resolves (
674- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
673+ . returns (
674+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
675675 )
676676 . onSecondCall ( )
677- . resolves (
678- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
677+ . returns (
678+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
679679 ) ;
680680
681681 const userData = getAtlasUserData ( ) ;
@@ -690,50 +690,34 @@ describe('AtlasUserData', function () {
690690
691691 const [ getUrl , getOptions ] = authenticatedFetchStub . firstCall . args ;
692692 expect ( getUrl ) . to . equal (
693- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
693+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
694694 ) ;
695695 expect ( getOptions . method ) . to . equal ( 'GET' ) ;
696696
697697 const [ putUrl , putOptions ] = authenticatedFetchStub . secondCall . args ;
698698 expect ( putUrl ) . to . equal (
699- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
699+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
700700 ) ;
701701 expect ( putOptions . method ) . to . equal ( 'PUT' ) ;
702702 expect ( putOptions . headers [ 'Content-Type' ] ) . to . equal ( 'application/json' ) ;
703703 } ) ;
704704
705- it ( 'throws error when authenticatedFetch throws an error ' , async function ( ) {
705+ it ( 'returns false when authenticatedFetch does not return 200 ' , async function ( ) {
706706 const getResponse = {
707707 data : JSON . stringify ( { name : 'Original Name' , hasDarkMode : true } ) ,
708708 } ;
709709
710- authenticatedFetchStub
711- . onFirstCall ( )
712- . resolves ( mockResponse ( getResponse ) )
713- . onSecondCall ( )
714- . rejects ( new Error ( 'HTTP 400: Bad Request' ) ) ;
710+ authenticatedFetchStub . resolves ( mockResponse ( getResponse , false , 400 ) ) ;
715711
716- getResourceUrlStub
717- . onFirstCall ( )
718- . resolves (
719- 'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj/test-id'
720- )
721- . onSecondCall ( )
722- . resolves (
723- 'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj/test-id'
724- ) ;
712+ getResourceUrlStub . returns (
713+ 'cluster-connection.cloud.mongodb.com/favoriteQueries/test-org/test-proj/test-id'
714+ ) ;
725715
726716 const userData = getAtlasUserData ( ) ;
727-
728- try {
729- await userData . updateAttributes ( 'test-id' , {
730- name : 'Updated' ,
731- } ) ;
732- expect . fail ( 'Expected method to throw an error' ) ;
733- } catch ( error ) {
734- expect ( error ) . to . be . instanceOf ( Error ) ;
735- expect ( ( error as Error ) . message ) . to . equal ( 'HTTP 400: Bad Request' ) ;
736- }
717+ const res = await userData . updateAttributes ( 'test-id' , {
718+ name : 'Updated' ,
719+ } ) ;
720+ expect ( res ) . equals ( false ) ;
737721 } ) ;
738722
739723 it ( 'uses custom serializer for request body' , async function ( ) {
@@ -750,12 +734,12 @@ describe('AtlasUserData', function () {
750734
751735 getResourceUrlStub
752736 . onFirstCall ( )
753- . resolves (
754- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj'
737+ . returns (
738+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj'
755739 )
756740 . onSecondCall ( )
757- . resolves (
758- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /test-org/test-proj/test-id'
741+ . returns (
742+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /test-org/test-proj/test-id'
759743 ) ;
760744
761745 const userData = new AtlasUserData ( getTestSchema ( ) , 'FavoriteQueries' , {
@@ -780,7 +764,7 @@ describe('AtlasUserData', function () {
780764 context ( 'AtlasUserData urls' , function ( ) {
781765 it ( 'constructs URL correctly for write operation' , async function ( ) {
782766 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
783- getResourceUrlStub . resolves (
767+ getResourceUrlStub . returns (
784768 'cluster-connection.cloud.mongodb.com/favoriteQueries/custom-org/custom-proj/test-id'
785769 ) ;
786770
@@ -795,23 +779,23 @@ describe('AtlasUserData', function () {
795779
796780 it ( 'constructs URL correctly for delete operation' , async function ( ) {
797781 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
798- getResourceUrlStub . resolves (
799- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org123/proj456/item789'
782+ getResourceUrlStub . returns (
783+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org123/proj456/item789'
800784 ) ;
801785
802786 const userData = getAtlasUserData ( { } , 'org123' , 'proj456' ) ;
803787 await userData . delete ( 'item789' ) ;
804788
805789 const [ url ] = authenticatedFetchStub . firstCall . args ;
806790 expect ( url ) . to . equal (
807- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org123/proj456/item789'
791+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org123/proj456/item789'
808792 ) ;
809793 } ) ;
810794
811795 it ( 'constructs URL correctly for read operation' , async function ( ) {
812796 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
813- getResourceUrlStub . resolves (
814- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org456/proj123'
797+ getResourceUrlStub . returns (
798+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org456/proj123'
815799 ) ;
816800
817801 const userData = getAtlasUserData ( { } , 'org456' , 'proj123' ) ;
@@ -820,7 +804,7 @@ describe('AtlasUserData', function () {
820804
821805 const [ url ] = authenticatedFetchStub . firstCall . args ;
822806 expect ( url ) . to . equal (
823- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org456/proj123'
807+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org456/proj123'
824808 ) ;
825809 } ) ;
826810
@@ -838,12 +822,12 @@ describe('AtlasUserData', function () {
838822
839823 getResourceUrlStub
840824 . onFirstCall ( )
841- . resolves (
842- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org123/proj456'
825+ . returns (
826+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org123/proj456'
843827 )
844828 . onSecondCall ( )
845- . resolves (
846- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org123/proj456/item789'
829+ . returns (
830+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org123/proj456/item789'
847831 ) ;
848832
849833 const userData = getAtlasUserData ( { } , 'org123' , 'proj456' ) ;
@@ -853,32 +837,32 @@ describe('AtlasUserData', function () {
853837
854838 const [ getUrl ] = authenticatedFetchStub . firstCall . args ;
855839 expect ( getUrl ) . to . equal (
856- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org123/proj456'
840+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org123/proj456'
857841 ) ;
858842
859843 const [ putUrl ] = authenticatedFetchStub . secondCall . args ;
860844 expect ( putUrl ) . to . equal (
861- 'cluster-connection.cloud.mongodb.com/FavoriteQueries /org123/proj456/item789'
845+ 'cluster-connection.cloud.mongodb.com/favoriteQueries /org123/proj456/item789'
862846 ) ;
863847 } ) ;
864848
865849 it ( 'constructs URL correctly for different types' , async function ( ) {
866850 authenticatedFetchStub . resolves ( mockResponse ( { } ) ) ;
867- getResourceUrlStub . resolves (
868- 'cluster-connection.cloud.mongodb.com/RecentQueries /org123/proj456'
851+ getResourceUrlStub . returns (
852+ 'cluster-connection.cloud.mongodb.com/recentQueries /org123/proj456'
869853 ) ;
870854
871855 const userData = getAtlasUserData (
872856 { } ,
873857 'org123' ,
874858 'proj456' ,
875- 'RecentQueries '
859+ 'recentQueries '
876860 ) ;
877861 await userData . write ( 'item789' , { name : 'Recent Item' } ) ;
878862
879863 const [ url ] = authenticatedFetchStub . firstCall . args ;
880864 expect ( url ) . to . equal (
881- 'cluster-connection.cloud.mongodb.com/RecentQueries /org123/proj456'
865+ 'cluster-connection.cloud.mongodb.com/recentQueries /org123/proj456'
882866 ) ;
883867 } ) ;
884868 } ) ;
0 commit comments