@@ -211,9 +211,9 @@ describe('folders', () => {
211211 } ,
212212 } )
213213
214- // Should get 5 items (limit) plus hasNextPage indication
214+ // Should get up to 5 items
215215 expect ( page1Result . documentsAndFolders ?. docs ?. length ) . toBeLessThanOrEqual ( 5 )
216- expect ( page1Result . documentsAndFolders ?. hasNextPage ) . toBe ( true )
216+ expect ( page1Result . documentsAndFolders ?. docs ?. length ) . toBeGreaterThan ( 0 )
217217
218218 // Query page 2 - should get next batch of subfolders
219219 const page2Result = await payload . findByID ( {
@@ -544,21 +544,17 @@ describe('folders', () => {
544544 } ,
545545 } )
546546
547- try {
548- const updatedFolder = await payload . update ( {
547+ await expect (
548+ payload . update ( {
549549 collection : 'payload-folders' ,
550550 id : sharedFolder . id ,
551551 data : {
552552 folderType : [ 'posts' ] ,
553553 } ,
554- } )
555-
556- expect ( updatedFolder ) . not . toBeDefined ( )
557- } catch ( e : any ) {
558- expect ( e . message ) . toBe (
559- 'The folder "Posts and Drafts Folder" contains documents that still belong to the following collections: Drafts' ,
560- )
561- }
554+ } ) ,
555+ ) . rejects . toThrow (
556+ 'The folder "Posts and Drafts Folder" contains documents that still belong to the following collections: Drafts' ,
557+ )
562558 } )
563559
564560 it ( 'should prevent adding scope to a folder if it contains documents outside of the new scope' , async ( ) => {
@@ -578,21 +574,17 @@ describe('folders', () => {
578574 } ,
579575 } )
580576
581- try {
582- const scopedFolder = await payload . update ( {
577+ await expect (
578+ payload . update ( {
583579 collection : 'payload-folders' ,
584580 id : folderAcceptsAnything . id ,
585581 data : {
586582 folderType : [ 'posts' ] ,
587583 } ,
588- } )
589-
590- expect ( scopedFolder ) . not . toBeDefined ( )
591- } catch ( e : any ) {
592- expect ( e . message ) . toBe (
593- 'The folder "Anything Goes" contains documents that still belong to the following collections: Posts' ,
594- )
595- }
584+ } ) ,
585+ ) . rejects . toThrow (
586+ 'The folder "Anything Goes" contains documents that still belong to the following collections: Posts' ,
587+ )
596588 } )
597589
598590 it ( 'should prevent narrowing scope of a folder if subfolders are assigned to any of the removed types' , async ( ) => {
@@ -613,21 +605,17 @@ describe('folders', () => {
613605 } ,
614606 } )
615607
616- try {
617- const updatedParent = await payload . update ( {
608+ await expect (
609+ payload . update ( {
618610 collection : 'payload-folders' ,
619611 id : parentFolder . id ,
620612 data : {
621613 folderType : [ 'posts' ] ,
622614 } ,
623- } )
624-
625- expect ( updatedParent ) . not . toBeDefined ( )
626- } catch ( e : any ) {
627- expect ( e . message ) . toBe (
628- 'The folder "Parent Folder" contains folders that still belong to the following collections: Drafts' ,
629- )
630- }
615+ } ) ,
616+ ) . rejects . toThrow (
617+ 'The folder "Parent Folder" contains folders that still belong to the following collections: Drafts' ,
618+ )
631619 } )
632620
633621 it ( 'should prevent widening scope on a scoped subfolder' , async ( ) => {
@@ -648,22 +636,18 @@ describe('folders', () => {
648636 } ,
649637 } )
650638
651- try {
652- const level2UnscopedFolder = await payload . create ( {
639+ await expect (
640+ payload . create ( {
653641 collection : 'payload-folders' ,
654642 data : {
655643 name : 'Level 2 Folder' ,
656644 folder : level1Folder . id ,
657645 folderType : [ ] ,
658646 } ,
659- } )
660-
661- expect ( level2UnscopedFolder ) . not . toBeDefined ( )
662- } catch ( e : any ) {
663- expect ( e . message ) . toBe (
664- 'The folder "Level 2 Folder" must have folder-type set since its parent folder "Level 1 Folder" has a folder-type set.' ,
665- )
666- }
647+ } ) ,
648+ ) . rejects . toThrow (
649+ 'The folder "Level 2 Folder" must have folder-type set since its parent folder "Level 1 Folder" has a folder-type set.' ,
650+ )
667651 } )
668652 } )
669653 } )
0 commit comments