admin/services/discountCodes.test.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

27 lines
847 B
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest'
import { GET_DISCOUNT_MANAGEMENT_BOOTSTRAP } from '@/services/discountCodes'
const get = vi.fn()
vi.mock('@/config/axios', () => ({ default: { get: (...args: unknown[]) => get(...args) } }))
describe('discount management bootstrap', () => {
afterEach(() => vi.clearAllMocks())
it('loads codes, report and redemptions through one HTTP request', async () => {
get.mockResolvedValue({
data: {
success: true,
data: { codes: { items: [] }, report: { totalCodes: 0 }, redemptions: { items: [] } },
},
})
const result = await GET_DISCOUNT_MANAGEMENT_BOOTSTRAP('event-1')
expect(result.ok).toBe(true)
expect(get).toHaveBeenCalledOnce()
expect(get).toHaveBeenCalledWith('events/event-1/discount-codes/management-bootstrap')
})
})