Skip to content

Commit

Permalink
added envelope property for joins (#440)
Browse files Browse the repository at this point in the history
* added envelope property for joins

* Refactoring

* Added isEnvelope property to test
  • Loading branch information
Vas9ka authored Feb 2, 2024
1 parent cea2d7f commit 81193c9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/fragmentarium/domain/Fragment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const config: Parameters<typeof Fragment['create']>[0] = {
note: '',
legacyData: '',
isInFragmentarium: true,
isEnvelope: true,
},
],
],
Expand Down
1 change: 1 addition & 0 deletions src/fragmentarium/domain/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Join {
readonly note: string
readonly legacyData: string
readonly isInFragmentarium: boolean
readonly isEnvelope: boolean
}

export type Joins = ReadonlyArray<ReadonlyArray<Join>>
7 changes: 7 additions & 0 deletions src/fragmentarium/ui/info/Details.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('All details', () => {
[
joinFactory.build({ isInFragmentarium: false }),
joinFactory.build({ isInFragmentarium: true }),
joinFactory.build({ isEnvelope: true }),
],
],
},
Expand All @@ -102,6 +103,12 @@ describe('All details', () => {
).toBeInTheDocument()
})

it(`Renders envelope icon for joins`, () => {
expect(screen.queryAllByLabelText('envelope icon').length).toBeGreaterThan(
0
)
})

it('Does not link to self', () => {
fragment.joins
.flat()
Expand Down
15 changes: 9 additions & 6 deletions src/fragmentarium/ui/info/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ function Joins({ fragment: { number, joins } }: Props): JSX.Element {
className="Details-joins__join"
key={`${groupIndex}-${index}`}
>
{index > 0 ? (
<>
<br />+{!join.isChecked && <sup>?</sup>}
</>
) : groupIndex > 0 ? (
{index > 0 || groupIndex > 0 ? (
<>
<br />
(+{!join.isChecked && <sup>?</sup>})
{join.isEnvelope ? (
<i
className="fa fa-envelope"
aria-label="envelope icon"
></i>
) : (
<>+{!join.isChecked && <sup>?</sup>}</>
)}
</>
) : (
''
Expand Down
2 changes: 2 additions & 0 deletions src/test-support/join-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const joinDtoFactory = Factory.define<
note: chance.sentence(),
legacyData: chance.sentence(),
isInFragmentarium: chance.bool(),
isEnvelope: chance.bool(),
}
})

Expand All @@ -32,4 +33,5 @@ export const joinFactory = Factory.define<Join>(({ sequence }) => ({
note: defaultChance.sentence(),
legacyData: defaultChance.sentence(),
isInFragmentarium: defaultChance.bool(),
isEnvelope: defaultChance.bool(),
}))
4 changes: 4 additions & 0 deletions src/test-support/test-fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export const fragmentDto: FragmentDto = {
note: '',
legacyData: '',
isInFragmentarium: true,
isEnvelope: true,
},
],
[
Expand All @@ -358,6 +359,7 @@ export const fragmentDto: FragmentDto = {
note: '',
legacyData: '',
isInFragmentarium: false,
isEnvelope: true,
},
],
],
Expand Down Expand Up @@ -440,6 +442,7 @@ export const fragment = new Fragment(
note: '',
legacyData: '',
isInFragmentarium: true,
isEnvelope: true,
},
],
[
Expand All @@ -451,6 +454,7 @@ export const fragment = new Fragment(
note: '',
legacyData: '',
isInFragmentarium: false,
isEnvelope: true,
},
],
],
Expand Down

0 comments on commit 81193c9

Please sign in to comment.