Add cart test without checkout button for full branch coverage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -232,6 +232,26 @@ describe('initCart', () => {
|
||||
expect(document.getElementById('cart-count').textContent).toBe('1')
|
||||
})
|
||||
|
||||
it('works without checkout button', () => {
|
||||
document.body.innerHTML = `
|
||||
<div id="billetterie">
|
||||
<div data-cart-item data-billet-id="1" data-price="10" data-max="5">
|
||||
<button data-cart-minus></button>
|
||||
<input data-cart-qty type="number" min="0" max="5" value="0" readonly>
|
||||
<button data-cart-plus></button>
|
||||
<span data-cart-line-total></span>
|
||||
</div>
|
||||
<span id="cart-total"></span><span id="cart-count"></span>
|
||||
</div>
|
||||
`
|
||||
initCart()
|
||||
|
||||
document.querySelector('[data-cart-plus]').click()
|
||||
|
||||
expect(document.getElementById('cart-total').textContent).toBe('10,00 \u20AC')
|
||||
expect(document.getElementById('cart-count').textContent).toBe('1')
|
||||
})
|
||||
|
||||
it('does not post when cart is empty on checkout', () => {
|
||||
const fetchMock = vi.fn()
|
||||
globalThis.fetch = fetchMock
|
||||
|
||||
Reference in New Issue
Block a user