071faa482c
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
66 lines
2.2 KiB
JavaScript
66 lines
2.2 KiB
JavaScript
import path from 'node:path';
|
|
|
|
import { describe, expect, test } from 'vitest';
|
|
|
|
import { HOST_BRIDGE_WECHAT_MINI_PROGRAM_CAPABILITIES } from '../../packages/shared/src/contracts/hostBridge.ts';
|
|
import { loadCommonJsModule } from '../test-utils/loadCommonJsModule.js';
|
|
|
|
const protocolPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/protocol.js',
|
|
);
|
|
const dispatchPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/dispatch.js',
|
|
);
|
|
const paymentPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/payment.js',
|
|
);
|
|
const shareGridPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/shareGrid.js',
|
|
);
|
|
const webViewPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/webView.js',
|
|
);
|
|
|
|
describe('wechat mini program host bridge protocol index', () => {
|
|
test('keeps native page routes and result keys centralized', () => {
|
|
const protocol = loadCommonJsModule(protocolPath);
|
|
|
|
expect(protocol.WECHAT_HOST_CAPABILITIES).toEqual(
|
|
HOST_BRIDGE_WECHAT_MINI_PROGRAM_CAPABILITIES,
|
|
);
|
|
expect(protocol.WECHAT_AUTH_PAGE_URL).toBe(
|
|
'/pages/web-view/index?authAction=login&returnTo=previous',
|
|
);
|
|
expect(protocol.WECHAT_PAY_PAGE_URL).toBe('/pages/wechat-pay/index');
|
|
expect(protocol.WECHAT_SHARE_GRID_PAGE_URL).toBe('/pages/share-grid/index');
|
|
expect(protocol.WECHAT_PAY_RESULT_HASH_KEY).toBe('wx_pay_result');
|
|
});
|
|
|
|
test('dispatch index exposes current bridge ability modules', () => {
|
|
const payment = loadCommonJsModule(paymentPath);
|
|
const protocol = loadCommonJsModule(protocolPath);
|
|
const shareGrid = loadCommonJsModule(shareGridPath);
|
|
const webView = loadCommonJsModule(webViewPath);
|
|
const dispatch = loadCommonJsModule(dispatchPath, {
|
|
'./payment': payment,
|
|
'./protocol': protocol,
|
|
'./shareGrid': shareGrid,
|
|
'./webView': webView,
|
|
});
|
|
|
|
expect(dispatch.protocol.WECHAT_PAY_PAGE_URL).toBe(
|
|
'/pages/wechat-pay/index',
|
|
);
|
|
expect(typeof dispatch.webView.resolveWebViewUrlFromRuntimeConfig).toBe(
|
|
'function',
|
|
);
|
|
expect(typeof dispatch.payment.requestWechatPayment).toBe('function');
|
|
expect(typeof dispatch.shareGrid.buildShareGridTilePlan).toBe('function');
|
|
});
|
|
});
|