84 行
3.8 KiB
TypeScript
84 行
3.8 KiB
TypeScript
import * as fs from 'fs';
|
||
import * as path from 'path';
|
||
|
||
describe('SkeletonScreen Architecture (TDD 骨架屏流光扫描与首屏加载体验门禁)', () => {
|
||
const rootDir = path.resolve(__dirname, '../../');
|
||
const skeletonComponentPath = path.join(rootDir, 'pwuniapp/components/SkeletonScreen.vue');
|
||
|
||
const pagePaths = {
|
||
index: path.join(rootDir, 'pwuniapp/pages/index/index.vue'),
|
||
activity: path.join(rootDir, 'pwuniapp/pages/activity/list.vue'),
|
||
community: path.join(rootDir, 'pwuniapp/pages/community/index.vue'),
|
||
expert: path.join(rootDir, 'pwuniapp/pages/expert/detail.vue')
|
||
};
|
||
|
||
describe('1. 骨架屏公共组件规范性验证 (SkeletonScreen.vue)', () => {
|
||
it('SkeletonScreen.vue 文件必须存在且格式有效', () => {
|
||
expect(fs.existsSync(skeletonComponentPath)).toBe(true);
|
||
const content = fs.readFileSync(skeletonComponentPath, 'utf-8');
|
||
expect(content.length).toBeGreaterThan(100);
|
||
});
|
||
|
||
it('必须支持四大核心业务形态:home、activity、community、expert', () => {
|
||
const content = fs.readFileSync(skeletonComponentPath, 'utf-8');
|
||
expect(content).toContain("type === 'home'");
|
||
expect(content).toContain("type === 'activity'");
|
||
expect(content).toContain("type === 'community'");
|
||
expect(content).toContain("type === 'expert'");
|
||
});
|
||
|
||
it('必须包含纯 CSS 骨架扫光动画与流光渐变关键帧', () => {
|
||
const content = fs.readFileSync(skeletonComponentPath, 'utf-8');
|
||
expect(content).toContain('skeletonShimmer');
|
||
expect(content).toContain('@keyframes skeletonShimmer');
|
||
expect(content).toContain('skeleton-shimmer');
|
||
});
|
||
|
||
it('必须完整支持双主题系统 (暗夜冷光与 theme-warm 浅色暖光)', () => {
|
||
const content = fs.readFileSync(skeletonComponentPath, 'utf-8');
|
||
expect(content).toContain('themeClass');
|
||
expect(content).toContain('.theme-warm');
|
||
});
|
||
|
||
it('骨架屏组件必须严格遵循零 Emoji 门禁规范', () => {
|
||
const content = fs.readFileSync(skeletonComponentPath, 'utf-8');
|
||
const emojiRegex = /[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;
|
||
expect(emojiRegex.test(content)).toBe(false);
|
||
});
|
||
});
|
||
|
||
describe('2. 四大核心业务页面骨架屏接入门禁', () => {
|
||
it('首页 (index.vue) 必须引入 SkeletonScreen 并配置 home 骨架屏与 isLoading 状态机', () => {
|
||
const content = fs.readFileSync(pagePaths.index, 'utf-8');
|
||
expect(content).toContain('SkeletonScreen');
|
||
expect(content).toContain('<skeleton-screen');
|
||
expect(content).toContain('type="home"');
|
||
expect(content).toContain('isLoading');
|
||
});
|
||
|
||
it('活动大厅 (activity/list.vue) 必须引入 SkeletonScreen 并配置 activity 骨架屏与 isLoading 状态机', () => {
|
||
const content = fs.readFileSync(pagePaths.activity, 'utf-8');
|
||
expect(content).toContain('SkeletonScreen');
|
||
expect(content).toContain('<skeleton-screen');
|
||
expect(content).toContain('type="activity"');
|
||
expect(content).toContain('isLoading');
|
||
});
|
||
|
||
it('友圈广场 (community/index.vue) 必须引入 SkeletonScreen 并配置 community 骨架屏与 isLoading 状态机', () => {
|
||
const content = fs.readFileSync(pagePaths.community, 'utf-8');
|
||
expect(content).toContain('SkeletonScreen');
|
||
expect(content).toContain('<skeleton-screen');
|
||
expect(content).toContain('type="community"');
|
||
expect(content).toContain('isLoading');
|
||
});
|
||
|
||
it('大神主页 (expert/detail.vue) 必须引入 SkeletonScreen 并配置 expert 骨架屏与 isLoading 状态机', () => {
|
||
const content = fs.readFileSync(pagePaths.expert, 'utf-8');
|
||
expect(content).toContain('SkeletonScreen');
|
||
expect(content).toContain('<skeleton-screen');
|
||
expect(content).toContain('type="expert"');
|
||
expect(content).toContain('isLoading');
|
||
});
|
||
});
|
||
});
|