import { describe, expect, it, vi } from 'vitest';
import { bindMessageApi, message } from './app-message';

describe('app message bridge', () => {
  it('delegates messages to the Ant Design App context instance', () => {
    const api = {
      success: vi.fn(),
      error: vi.fn(),
      warning: vi.fn(),
    };
    bindMessageApi(api as never);

    message.success('保存成功');
    message.error('保存失败');
    message.warning('请检查');

    expect(api.success).toHaveBeenCalledWith('保存成功');
    expect(api.error).toHaveBeenCalledWith('保存失败');
    expect(api.warning).toHaveBeenCalledWith('请检查');
  });
});
