46 lines
2.0 KiB
JavaScript
46 lines
2.0 KiB
JavaScript
|
|
const fs = require('fs');
|
||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
// 读取 mockData.js 并提取 homework 数据
|
||
|
|
const mockDataPath = path.join(__dirname, 'src/data/mockData.js');
|
||
|
|
const mockDataContent = fs.readFileSync(mockDataPath, 'utf-8');
|
||
|
|
|
||
|
|
// 简单验证关键结构
|
||
|
|
const checks = {
|
||
|
|
'复合能力课存在': /name: "复合能力课"/.test(mockDataContent),
|
||
|
|
'垂直能力课存在': /name: "垂直能力课"/.test(mockDataContent),
|
||
|
|
'复合能力课有list字段': /name: "复合能力课"[^]*?list: \[/.test(mockDataContent),
|
||
|
|
'垂直能力课有list字段': /name: "垂直能力课"[^]*?list: \[/.test(mockDataContent),
|
||
|
|
'复合能力课有units字段': /name: "复合能力课"[^]*?units: \[/.test(mockDataContent),
|
||
|
|
'垂直能力课有units字段': /name: "垂直能力课"[^]*?units: \[/.test(mockDataContent),
|
||
|
|
'展会主题与品牌定位有isShowCase标记': /name: "展会主题与品牌定位".*isShowCase: true/.test(mockDataContent)
|
||
|
|
};
|
||
|
|
|
||
|
|
console.log('===== homework 数据结构验证 =====\n');
|
||
|
|
|
||
|
|
let allPassed = true;
|
||
|
|
Object.entries(checks).forEach(([checkName, result]) => {
|
||
|
|
const status = result ? '✅' : '❌';
|
||
|
|
console.log(`${status} ${checkName}`);
|
||
|
|
if (!result) allPassed = false;
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('\n===== 课程数量统计 =====\n');
|
||
|
|
|
||
|
|
// 统计 list 中的课程数量
|
||
|
|
const compoundListMatch = mockDataContent.match(/name: "复合能力课"[\s\S]*?list: \[([\s\S]*?)\]\s*\}/);
|
||
|
|
const verticalListMatch = mockDataContent.match(/name: "垂直能力课"[\s\S]*?list: \[([\s\S]*?)\]\s*\}/);
|
||
|
|
|
||
|
|
if (compoundListMatch) {
|
||
|
|
const compoundCourses = (compoundListMatch[1].match(/\{ id:/g) || []).length;
|
||
|
|
console.log(`复合能力课 list 中的课程数: ${compoundCourses}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (verticalListMatch) {
|
||
|
|
const verticalCourses = (verticalListMatch[1].match(/\{ id:/g) || []).length;
|
||
|
|
console.log(`垂直能力课 list 中的课程数: ${verticalCourses}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log('\n===== 总结 =====\n');
|
||
|
|
console.log(allPassed ? '✅ 所有检查通过!' : '❌ 存在问题,请检查上述失败项');
|