feat: consulta pública de pedidos por código
This commit is contained in:
34
tests/unit/services/django-api.spec.js
Normal file
34
tests/unit/services/django-api.spec.js
Normal file
@@ -0,0 +1,34 @@
|
||||
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' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user