Add missing JS coverage: designer save else branch, calculator default rates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,25 @@ describe('initBilletDesigner', () => {
|
|||||||
expect(fetchMock).not.toHaveBeenCalled()
|
expect(fetchMock).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('save includes non-checkbox input values in form data', () => {
|
||||||
|
const fetchMock = vi.fn().mockResolvedValue({ ok: true })
|
||||||
|
globalThis.fetch = fetchMock
|
||||||
|
|
||||||
|
document.body.innerHTML = `
|
||||||
|
<div id="billet-designer" data-preview-url="/preview" data-save-url="/save">
|
||||||
|
<input type="text" name="invitation_title" value="VIP Pass">
|
||||||
|
<iframe id="billet-preview-frame" src="/preview"></iframe>
|
||||||
|
<button id="billet-save-design"></button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
|
||||||
|
initBilletDesigner()
|
||||||
|
document.getElementById('billet-save-design').click()
|
||||||
|
|
||||||
|
const formData = fetchMock.mock.calls[0][1].body
|
||||||
|
expect(formData.get('invitation_title')).toBe('VIP Pass')
|
||||||
|
})
|
||||||
|
|
||||||
it('save includes checkbox values in form data', () => {
|
it('save includes checkbox values in form data', () => {
|
||||||
const fetchMock = vi.fn().mockResolvedValue({ ok: true })
|
const fetchMock = vi.fn().mockResolvedValue({ ok: true })
|
||||||
globalThis.fetch = fetchMock
|
globalThis.fetch = fetchMock
|
||||||
|
|||||||
@@ -15,6 +15,23 @@ describe('initCommissionCalculator', () => {
|
|||||||
expect(() => initCommissionCalculator()).not.toThrow()
|
expect(() => initCommissionCalculator()).not.toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('uses default stripe rate and fixed when not provided', () => {
|
||||||
|
document.body.innerHTML = `
|
||||||
|
<input type="number" id="billet_price" value="10">
|
||||||
|
<div id="commission-calculator" data-eticket-rate="0">
|
||||||
|
<span id="calc-price"></span>
|
||||||
|
<span id="calc-eticket"></span>
|
||||||
|
<span id="calc-stripe"></span>
|
||||||
|
<span id="calc-total"></span>
|
||||||
|
<span id="calc-net"></span>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
initCommissionCalculator()
|
||||||
|
|
||||||
|
// Default stripe: 10 * 1.5% + 0.25 = 0.40
|
||||||
|
expect(document.getElementById('calc-stripe').textContent).toBe('- 0,40 \u20AC')
|
||||||
|
})
|
||||||
|
|
||||||
function setupCalculator(eticketRate = '5', price = '') {
|
function setupCalculator(eticketRate = '5', price = '') {
|
||||||
document.body.innerHTML = `
|
document.body.innerHTML = `
|
||||||
<input type="number" id="billet_price" value="${price}">
|
<input type="number" id="billet_price" value="${price}">
|
||||||
|
|||||||
Reference in New Issue
Block a user