35 lines
957 B
JavaScript
35 lines
957 B
JavaScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import http from '@/services/http'
|
|
import DjangoApi from '@/services/django-api'
|
|
|
|
vi.mock('@/services/http', () => ({
|
|
default: {
|
|
get: vi.fn(),
|
|
post: vi.fn(),
|
|
patch: vi.fn(),
|
|
put: vi.fn(),
|
|
delete: vi.fn(),
|
|
},
|
|
}))
|
|
|
|
describe('DjangoApi.getPublicOrderSummary', () => {
|
|
beforeEach(() => {
|
|
vi.stubEnv('VITE_DJANGO_BASE_URL', 'http://backend.test')
|
|
http.get.mockReset()
|
|
http.get.mockResolvedValue({ data: { code: 'abc123', type: 'sale' } })
|
|
})
|
|
|
|
it('consulta el resumen público por código en la ruta resumen_publico', async () => {
|
|
const api = new DjangoApi()
|
|
|
|
const result = await api.getPublicOrderSummary('abc123')
|
|
|
|
expect(http.get).toHaveBeenCalledTimes(1)
|
|
expect(http.get).toHaveBeenCalledWith(
|
|
'http://backend.test/don_confiao/api/resumen_publico/abc123'
|
|
)
|
|
expect(result).toEqual({ code: 'abc123', type: 'sale' })
|
|
})
|
|
})
|