Skip to content

Commit

Permalink
tests: complete most of the test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Nov 14, 2024
1 parent 1afcaa8 commit 6502c80
Show file tree
Hide file tree
Showing 4 changed files with 962 additions and 826 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ export class CollectionFormHelper {
public static formatCollectionContactsToFormContacts(
collectionContacts: CollectionContact[]
): CollectionFormContactValue[] {
if (collectionContacts.length === 0) {
return [{ value: '' }]
}

return collectionContacts.map((contact) => ({
value: contact.email
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type EditCreateCollectionFormProps =
| {
mode: 'create'
user: User
collection?: never
collection?: never // In create mode, collection is undefined, we only have parentCollection
parentCollection: Collection
collectionRepository: CollectionRepository
metadataBlockInfoRepository: MetadataBlockInfoRepository
Expand All @@ -41,7 +41,7 @@ type EditCreateCollectionFormProps =
mode: 'edit'
user: User
collection: Collection
parentCollection?: ParentCollectionDataInEdition
parentCollection?: ParentCollectionDataInEdition // In edit mode, parentCollection could be undefined in case of root collection
collectionRepository: CollectionRepository
metadataBlockInfoRepository: MetadataBlockInfoRepository
}
Expand Down Expand Up @@ -104,7 +104,7 @@ export const EditCreateCollectionForm = ({
}, [allMetadataBlocksInfo])

const collectionInputLevelsToFormat =
mode === 'edit' ? collection?.inputLevels : parentCollection?.inputLevels
mode === 'edit' ? collection.inputLevels : parentCollection.inputLevels

const formattedCollectionInputLevels: FormattedCollectionInputLevelsWithoutParentBlockName =
useDeepCompareMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@ describe('CollectionFormHelper', () => {
expect(result).to.deep.equal(expected)
})

it('formats empty collection contacts to empty form contacts values ', () => {
const collectionContacts: CollectionContact[] = []

const result = CollectionFormHelper.formatCollectionContactsToFormContacts(collectionContacts)

expect(result).to.deep.equal([{ value: '' }])
})

describe('defineShouldCheckUseFromParent', () => {
it('returns false if is on edit mode and is editing the root collection', () => {
const result = CollectionFormHelper.defineShouldCheckUseFromParent(true, true, true)
Expand Down
Loading

0 comments on commit 6502c80

Please sign in to comment.