@@ -37,7 +37,7 @@ import { ROOT_COLLECTION_ID } from '../../../src/collections/domain/models/Colle
3737import {
3838 createCollectionFeaturedItemViaApi ,
3939 createImageFile ,
40- deleteAllCollectionFeaturedItemsViaApi ,
40+ deleteCollectionFeaturedItemsViaApi ,
4141 deleteCollectionFeaturedItemViaApi
4242} from '../../testHelpers/collections/collectionFeaturedItemsHelper'
4343
@@ -946,7 +946,7 @@ describe('CollectionsRepository', () => {
946946 describe ( 'updateCollectionFeaturedItems' , ( ) => {
947947 afterAll ( async ( ) => {
948948 try {
949- await deleteAllCollectionFeaturedItemsViaApi ( testCollectionAlias )
949+ await deleteCollectionFeaturedItemsViaApi ( testCollectionAlias )
950950 } catch ( error ) {
951951 throw new Error (
952952 `Tests afterAll(): Error while deleting all featured items from collection: ${ testCollectionAlias } `
@@ -1002,46 +1002,56 @@ describe('CollectionsRepository', () => {
10021002 } )
10031003 } )
10041004
1005- // describe('deleteAllCollectionFeaturedItems', () => {
1006-
1007- // beforeAll(async () => {
1008- // try {
1009- // await createCollectionFeaturedItemViaApi(testCollectionAlias, {
1010- // content: '<p class="rte-paragraph">Test content</p>',
1011- // displayOrder: 1,
1012- // withFile: true,
1013- // fileName: 'featured-item-test-image.png'
1014- // })
1015- // await createCollectionFeaturedItemViaApi(testCollectionAlias, {
1016- // content: '<p class="rte-paragraph">Test content 2</p>',
1017- // displayOrder: 2,
1018- // withFile: false
1019- // })
1020- // await createCollectionFeaturedItemViaApi(testCollectionAlias, {
1021- // content: '<p class="rte-paragraph">Test content 3</p>',
1022- // displayOrder: 3,
1023- // withFile: false
1024- // })
1025-
1026- // } catch (error) {
1027- // throw new Error(
1028- // `Tests afterAll(): Error while deleting all featured items from collection: ${testCollectionAlias}`
1029- // )
1030- // }
1031- // })
1032-
1033- // it('should delete all collection featured items', async () => {
1034- // const featuredItemsResponseFirst = await sut.getCollectionFeaturedItems(testCollectionAlias)
1035-
1036- // console.log({ featuredItemsResponseFirst })
1037-
1038- // await deleteAllCollectionFeaturedItemsViaApi(testCollectionAlias)
1039-
1040- // const featuredItemsResponse = await sut.getCollectionFeaturedItems(testCollectionAlias)
1041-
1042- // console.log({ featuredItemsResponse })
1043-
1044- // expect(featuredItemsResponse).toStrictEqual([])
1045- // })
1046- // })
1005+ describe ( 'deleteCollectionFeaturedItems' , ( ) => {
1006+ beforeAll ( async ( ) => {
1007+ try {
1008+ await createCollectionFeaturedItemViaApi ( testCollectionAlias , {
1009+ content : '<p class="rte-paragraph">Test content</p>' ,
1010+ displayOrder : 1 ,
1011+ withFile : true ,
1012+ fileName : 'featured-item-test-image.png'
1013+ } )
1014+ await createCollectionFeaturedItemViaApi ( testCollectionAlias , {
1015+ content : '<p class="rte-paragraph">Test content 2</p>' ,
1016+ displayOrder : 2 ,
1017+ withFile : false
1018+ } )
1019+ await createCollectionFeaturedItemViaApi ( testCollectionAlias , {
1020+ content : '<p class="rte-paragraph">Test content 3</p>' ,
1021+ displayOrder : 3 ,
1022+ withFile : false
1023+ } )
1024+ } catch ( error ) {
1025+ throw new Error (
1026+ `Tests afterAll(): Error while creating test featured items for collection: ${ testCollectionAlias } `
1027+ )
1028+ }
1029+ } )
1030+
1031+ afterAll ( async ( ) => {
1032+ try {
1033+ await deleteCollectionFeaturedItemsViaApi ( testCollectionAlias )
1034+ } catch ( error ) {
1035+ throw new Error (
1036+ `Tests afterAll(): Error while deleting test collection featured items: ${ testCollectionAlias } `
1037+ )
1038+ }
1039+ } )
1040+
1041+ it ( 'should delete all collection featured items' , async ( ) => {
1042+ const featuredItemsResponseBeforeDeletion = await sut . getCollectionFeaturedItems (
1043+ testCollectionAlias
1044+ )
1045+
1046+ expect ( featuredItemsResponseBeforeDeletion ) . toHaveLength ( 3 )
1047+
1048+ await sut . deleteCollectionFeaturedItems ( testCollectionAlias )
1049+
1050+ const featuredItemsResponseAfterDeletion = await sut . getCollectionFeaturedItems (
1051+ testCollectionAlias
1052+ )
1053+
1054+ expect ( featuredItemsResponseAfterDeletion ) . toStrictEqual ( [ ] )
1055+ } )
1056+ } )
10471057} )
0 commit comments