Files

27 lines
877 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it, vi } from 'vitest';
// 单测不碰真实总线:mock 掉 bus/nats,真实模块(及其 NATS 连接)永不求值
vi.mock('../../src/shared/bus/nats', () => ({
checkNats: async () => 'ok' as const,
}));
import { buildApp } from '../../src/app/app';
import { config } from '../../src/shared/config';
describe('health', () => {
it('nats 探活 ok(mock)时返回 200', async () => {
const res = await buildApp().request('/health');
expect(res.status).toBe(200);
const body = (await res.json()) as {
ok: boolean;
service: string;
checks: Record<string, string>;
};
expect(body.ok).toBe(true);
expect(body.service).toBe('bpos-service-gateway');
expect(config.port).toBe(8800);
expect(config.keycloak.clientId).toBe('api-gateway');
expect(body.checks['nats']).toBe('ok');
});
});