66 行
2.8 KiB
JavaScript
66 行
2.8 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
|
|
function assert(condition, testName, detail = '') {
|
|
if (condition) {
|
|
console.log(` [PASS] ${testName}`);
|
|
passed++;
|
|
} else {
|
|
console.error(` [FAIL] ${testName} - ${detail}`);
|
|
failed++;
|
|
}
|
|
}
|
|
|
|
console.log("========================================================");
|
|
console.log(" 我的页面资产卡片(余额、马豆、兑换券)功能规格测试");
|
|
console.log("========================================================\n");
|
|
|
|
// 1. 验证 pages/index/user.vue
|
|
const userVuePath = path.resolve(__dirname, '../uniapp/pages/index/user.vue');
|
|
assert(fs.existsSync(userVuePath), 'user.vue 文件存在');
|
|
const userVueContent = fs.readFileSync(userVuePath, 'utf-8');
|
|
|
|
assert(
|
|
userVueContent.includes('walletCard') && (userVueContent.includes('layoutBlocks') || userVueContent.includes('walletBlock')),
|
|
'user.vue 中包含 walletCard 资产卡片的保底注入机制',
|
|
'未在 user.vue 中检测到 walletCard 逻辑'
|
|
);
|
|
|
|
assert(
|
|
!userVueContent.includes('v-for="(item, index) in template.data"'),
|
|
'user.vue 模板遍历已升级为支持动态补充资产卡片的 blocks 计算列表',
|
|
'仍直接遍历未补充 walletCard 的 template.data'
|
|
);
|
|
|
|
// 2. 验证 sheep/components/s-wallet-card/s-wallet-card.vue
|
|
const walletCardPath = path.resolve(__dirname, '../uniapp/sheep/components/s-wallet-card/s-wallet-card.vue');
|
|
assert(fs.existsSync(walletCardPath), 's-wallet-card.vue 文件存在');
|
|
const walletCardContent = fs.readFileSync(walletCardPath, 'utf-8');
|
|
|
|
assert(
|
|
walletCardContent.includes('userInfo.money') && walletCardContent.includes('/pages/user/wallet/money') && (walletCardContent.includes('余额') || walletCardContent.includes('账户余额')),
|
|
's-wallet-card.vue 包含余额项、正确数据绑定与跳转路由',
|
|
'缺少余额配置或路由不正确'
|
|
);
|
|
|
|
assert(
|
|
walletCardContent.includes('displayMadow') && walletCardContent.includes('/pages/commission/madow') && walletCardContent.includes('马豆'),
|
|
's-wallet-card.vue 包含马豆项、正确数据绑定与跳转路由',
|
|
'缺少马豆配置或路由不正确'
|
|
);
|
|
|
|
assert(
|
|
walletCardContent.includes('voucher_available') && walletCardContent.includes('/pages/commission/voucher') && (walletCardContent.includes('兑换券') || walletCardContent.includes('兑换卷')),
|
|
's-wallet-card.vue 包含兑换券(卷)项、正确数据绑定与跳转路由',
|
|
'缺少兑换券配置或路由不正确'
|
|
);
|
|
|
|
console.log("\n--------------------------------------------------------");
|
|
console.log(`测试执行结果: 通过 ${passed} 项, 失败 ${failed} 项`);
|
|
console.log("========================================================");
|
|
|
|
process.exit(failed === 0 ? 0 : 1);
|