Skip to content

Commit 71af9f1

Browse files
authored
Merge branch 'develop' into fix-typo-first-checkin
2 parents 6a48973 + 002e837 commit 71af9f1

File tree

1 file changed

+25
-0
lines changed
  • packages/template-retail-react-app/app/components/product-view

1 file changed

+25
-0
lines changed

packages/template-retail-react-app/app/components/product-view/index.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,31 @@ test('Product View can update quantity', async () => {
128128
})
129129
})
130130

131+
test('Product View handles invalid quantity inputs', async () => {
132+
const user = userEvent.setup()
133+
134+
// Any invalid input should be reset to minOrderQuantity
135+
await renderWithProviders(<MockComponent product={mockProductDetail} />)
136+
137+
const quantityInput = screen.getByRole('spinbutton', {name: /quantity/i})
138+
const minQuantity = mockProductDetail.minOrderQuantity.toString()
139+
140+
// Quantity is empty
141+
await user.clear(quantityInput)
142+
await user.tab()
143+
await waitFor(() => {
144+
expect(quantityInput).toHaveValue(minQuantity)
145+
})
146+
147+
// Quantity is zero
148+
await user.clear(quantityInput)
149+
await user.type(quantityInput, '0')
150+
await user.tab()
151+
await waitFor(() => {
152+
expect(quantityInput).toHaveValue(minQuantity)
153+
})
154+
})
155+
131156
describe('ProductView Component', () => {
132157
test('increases quantity when increment button is clicked', async () => {
133158
const user = userEvent.setup()

0 commit comments

Comments
 (0)