- Introduced a new 'Test frontend' stage in the Jenkinsfile to run unit tests using Vitest in a Docker container. - Updated Vite configuration to conditionally include client and server test projects based on the CI environment. - Modified backend health check tests to skip execution in CI environments. - Adjusted test for constructing backend asset URLs to reflect default behavior when no base URL is provided.
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { getBackendAssetUrl } from './utils'
|
|
|
|
describe('getBackendAssetUrl', () => {
|
|
|
|
it('devuelve string vacío si path es null', () => {
|
|
expect(getBackendAssetUrl(null)).toBe('')
|
|
})
|
|
|
|
it('devuelve string vacío si path es undefined', () => {
|
|
expect(getBackendAssetUrl(undefined)).toBe('')
|
|
})
|
|
|
|
it('devuelve la URL tal cual si ya es completa', () => {
|
|
expect(getBackendAssetUrl('http://ejemplo.com/archivo.png')).toBe('http://ejemplo.com/archivo.png')
|
|
})
|
|
|
|
it('evita duplicar /api en la URL', () => {
|
|
expect(getBackendAssetUrl('/api/v1/items', 'http://localhost:8000/api')).toBe('http://localhost:8000/api/v1/items')
|
|
})
|
|
|
|
it('construye URL completa para ruta relativa (VITE_API_URL por defecto host:8000)', () => {
|
|
// getBackendAssetUrl solo acepta path; la base sale de VITE o fallback http://localhost:8000
|
|
expect(getBackendAssetUrl('/uploads/file.png')).toBe('http://localhost:8000/uploads/file.png')
|
|
})
|
|
|
|
}) |