7609c37d5f
新增 miniprogram/shell 承接微信 Page 生命周期与 wx 容器调用 收窄微信页面入口为 shell 页面工厂装配 更新三端 host-bridge/shell 目录门禁与认证 smoke 补充微信 shell 测试与 CommonJS 测试加载工具 同步宿主壳架构文档和项目共享记忆 补齐 api-server 外部生成测试 fixture 更新时间字段
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import path from 'node:path';
|
|
|
|
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
|
|
import { loadCommonJsModule } from '../test-utils/loadCommonJsModule.js';
|
|
|
|
const shareGridBridgePath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/wechatHostBridgeShareGrid.js',
|
|
);
|
|
const shareGridShellPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/shell/wechatShellShareGrid.js',
|
|
);
|
|
|
|
let createWechatShareGridPage;
|
|
|
|
function createPage() {
|
|
const page = createWechatShareGridPage();
|
|
return {
|
|
...page,
|
|
data: { ...page.data },
|
|
setData(patch) {
|
|
Object.assign(this.data, patch);
|
|
},
|
|
};
|
|
}
|
|
|
|
describe('wechat share-grid shell page', () => {
|
|
beforeEach(() => {
|
|
globalThis.wx = {
|
|
navigateBack: vi.fn(),
|
|
};
|
|
const shareGridBridge = loadCommonJsModule(shareGridBridgePath);
|
|
const shareGridShell = loadCommonJsModule(shareGridShellPath, {
|
|
'../host-bridge/wechatHostBridgeShareGrid': shareGridBridge,
|
|
});
|
|
createWechatShareGridPage = shareGridShell.createWechatShareGridPage;
|
|
});
|
|
|
|
test('shows a clear error when imageUrl is missing', async () => {
|
|
const page = createPage();
|
|
|
|
await page.onLoad({});
|
|
|
|
expect(page.data.loading).toBe(false);
|
|
expect(page.data.errorMessage).toBe('缺少封面图。');
|
|
});
|
|
});
|