M0-M11 狩夜人笔记初始实现:11里程碑+86测试

This commit is contained in:
hunter-dev
2026-08-24 20:35:22 +08:00
commit 3ebd33536b
106 changed files with 10490 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
/** @vitest-environment jsdom */
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { EffectEngine } from '../../apps/desktop/src/renderer/features/effects/effect-engine';
// stub requestAnimationFrame
beforeEach(() => {
globalThis.requestAnimationFrame = ((cb: FrameRequestCallback) => { return 0 as any; }) as any;
globalThis.cancelAnimationFrame = (() => {}) as any;
});
describe('M6 EffectEngine 配置与降级 (FR-A11)', () => {
it('setType/setColor 改变状态', () => {
const e = new EffectEngine();
e.setType('particle'); e.setColor('#ff0000');
e.disable();
// disable 后 type 为 off
expect(e.isActive()).toBe(false);
});
it('attach 到 canvas 不抛错', () => {
const canvas = document.createElement('canvas');
document.body.appendChild(canvas);
const e = new EffectEngine();
expect(() => e.attach(canvas)).not.toThrow();
e.detach();
});
it('detach 后 isActive 为 false', () => {
const canvas = document.createElement('canvas');
const e = new EffectEngine();
e.attach(canvas);
e.detach();
expect(e.isActive()).toBe(false);
});
});