import { describe, it, expect } from 'vitest';
import { Sprite, Texture } from 'pixi.js';
import { SpriteFlash } from '../spriteFx';
describe('SpriteFlash', () => {
it('вспышка перекрашивает спрайт и возвращает базовый tint', () => {
const sprite = new Sprite(Texture.WHITE);
const flash = new SpriteFlash(sprite, 0xff0000, 0.15);
flash.start();
flash.update(1 / 60);
expect(sprite.tint).not.toBe(0xffffff);
for (let i = 0; i < 15; i++) flash.update(1 / 60); // 0.15+ с — доиграл
expect(sprite.tint).toBe(0xffffff);
});
it('destroyed следует за разрушением спрайта (самозачистка из реестра)', () => {
const sprite = new Sprite(Texture.WHITE);
const flash = new SpriteFlash(sprite, 0xff0000);
expect(flash.destroyed).toBe(false);
flash.update(1 / 60); // неактивен — no-op
sprite.destroy();
expect(flash.destroyed).toBe(true);
});
});