customer-orders-web/src/api/client.test.ts
José René White Enciso e8db327e6f feat(customer-web): add web baseline
Why: establish baseline web runtime scaffold before wave implementation.

What: add react app structure, docker runtime assets, docs runbooks, and ignore policy updates.

Rule: keep technical intent and repository workflow compliance.
2026-03-08 15:53:49 -06:00

27 lines
842 B
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest';
import { getApiBaseUrl } from './client';
describe('getApiBaseUrl', () => {
afterEach(() => {
delete window.__APP_CONFIG__;
vi.unstubAllEnvs();
});
it('uses runtime-config API base URL when present', () => {
window.__APP_CONFIG__ = { API_BASE_URL: 'http://runtime.example' };
vi.stubEnv('VITE_API_BASE_URL', 'http://env.example');
expect(getApiBaseUrl()).toBe('http://runtime.example');
});
it('falls back to VITE_API_BASE_URL when runtime-config is missing', () => {
vi.stubEnv('VITE_API_BASE_URL', 'http://env.example');
expect(getApiBaseUrl()).toBe('http://env.example');
});
it('falls back to localhost default when both runtime and env are missing', () => {
expect(getApiBaseUrl()).toBe('http://localhost:8080');
});
});