40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
vi.mock('./client', () => ({
|
|
getJson: vi.fn(),
|
|
postJson: vi.fn()
|
|
}));
|
|
|
|
import { getJson, postJson } from './client';
|
|
import { capturePosPayment, loadDashboard } from './dashboardApi';
|
|
|
|
describe('pos transactions dashboard api', () => {
|
|
it('builds encoded summary endpoint path', async () => {
|
|
vi.mocked(getJson).mockResolvedValue({ ok: true });
|
|
|
|
await loadDashboard('ctx pos/1');
|
|
|
|
expect(getJson).toHaveBeenCalledWith('/api/pos/transactions/summary?contextId=ctx%20pos%2F1');
|
|
});
|
|
|
|
it('posts payment capture payload', async () => {
|
|
vi.mocked(postJson).mockResolvedValue({ succeeded: true });
|
|
|
|
await capturePosPayment({
|
|
contextId: 'ctx',
|
|
transactionId: 'POS-1',
|
|
amount: 14.5,
|
|
currency: 'USD',
|
|
paymentMethod: 'card'
|
|
});
|
|
|
|
expect(postJson).toHaveBeenCalledWith('/api/pos/transactions/payments', {
|
|
contextId: 'ctx',
|
|
transactionId: 'POS-1',
|
|
amount: 14.5,
|
|
currency: 'USD',
|
|
paymentMethod: 'card'
|
|
});
|
|
});
|
|
});
|