Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
(PC-6859): Desk: display isbn for books
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliochka committed Oct 27, 2021
1 parent ee40b9b commit b613ade
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/pages/Desk/Desk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,16 @@ class Desk extends Component {
{`${booking.price} €`}
</div>
</div>
{'ean13' in booking && (
<div>
<div className="desk-label">
{'Isbn : '}
</div>
<div className="desk-value">
{booking.ean13}
</div>
</div>
)}
</div>
)}

Expand Down
45 changes: 45 additions & 0 deletions src/components/pages/Desk/__specs__/Desk.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ describe('src | components | Desk', () => {
offerName: 'Fake offer',
userName: 'Fake user name',
price: 40,
ean13: 'isbn',
})
renderDesk(props)
const tokenInput = screen.getByLabelText('Contremarque')
Expand All @@ -171,8 +172,52 @@ describe('src | components | Desk', () => {
expect(bookingDate).toBeInTheDocument()
const bookingPrice = await queryByTextTrimHtml(screen, 'Prix : 40 €')
expect(bookingPrice).toBeInTheDocument()
const bookingIsbn = await queryByTextTrimHtml(screen, 'Isbn : isbn')
expect(bookingIsbn).toBeInTheDocument()
})

it('should display isbn line with empty informations if offer is a book', async () => {
// given
jest.spyOn(props, 'getBooking').mockResolvedValue({
datetime: '2020-10-23T20:00:00Z',
offerName: 'Fake offer',
userName: 'Fake user name',
price: 40,
ean13: '',
})
renderDesk(props)
const tokenInput = screen.getByLabelText('Contremarque')

// when
fireEvent.change(tokenInput, { target: { value: 'MEFA01' } })

// then
await screen.findByRole('button', { name: 'Valider la contremarque' })
const bookingIsbn = await queryByTextTrimHtml(screen, 'Isbn :')
expect(bookingIsbn).toBeInTheDocument()
})

it('should not display isbn line if offer is not a book', async () => {
// given
jest.spyOn(props, 'getBooking').mockResolvedValue({
datetime: '2020-10-23T20:00:00Z',
offerName: 'Fake offer',
userName: 'Fake user name',
price: 40,
})
renderDesk(props)
const tokenInput = screen.getByLabelText('Contremarque')

// when
fireEvent.change(tokenInput, { target: { value: 'MEFA01' } })

// then
await screen.findByRole('button', { name: 'Valider la contremarque' })
const bookingIsbn = await queryByTextTrimHtml(screen, 'Isbn :')
expect(bookingIsbn).not.toBeInTheDocument()
})


it('should display an error message when token validation fails', async () => {
// given
jest.spyOn(props, 'getBooking').mockRejectedValue({
Expand Down

0 comments on commit b613ade

Please sign in to comment.