Skip to content

Commit

Permalink
feat: [closes #443] show age for cows offered for trade (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquisDeMizzle authored Feb 11, 2024
1 parent f588c7b commit 0c9d4f4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/CowCard/Subheader/Subheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const Subheader = (
return (
<div {...{ className: 'Subheader' }}>
<Bloodline {...{ colorsInBloodline: cow.colorsInBloodline }} />
{isCowPurchased && (
{(isCowPurchased || cowIdOfferedForTrade) && (
<p>
{cow.daysOld} {cow.daysOld === 1 ? 'day' : 'days'} old
</p>
Expand Down
30 changes: 30 additions & 0 deletions src/components/CowCard/Subheader/Subheader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,34 @@ describe('Subheader', () => {
expect(value).toBeInTheDocument()
})
})

describe('cow age display', () => {
const ageRegex = /days? old/
test('displays when purchased', () => {
render(<Subheader {...baseProps} isCowPurchased={true} />)

const age = screen.queryByText(ageRegex)
expect(age).not.toBeNull()
})

test('displays when offered as trade', () => {
render(
<Subheader
{...baseProps}
cowIdOfferedForTrade="1234"
isCowPurchased={false}
/>
)

const age = screen.queryByText(ageRegex)
expect(age).not.toBeNull()
})

test('hidden when unpurchased from shop', () => {
render(<Subheader {...baseProps} isCowPurchased={false} />)

const age = screen.queryByText(ageRegex)
expect(age).toBeNull()
})
})
})

0 comments on commit 0c9d4f4

Please sign in to comment.