5180 fichiers 38.5 Mo 0 téléchargements 246 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / hooks / avatar-effects / useAvatarEffects.test.ts
useAvatarEffects.test.ts 1.7 Ko Télécharger le fichier
/* @vitest-environment jsdom */
import { describe, expect, it } from 'vitest';
import { mergeAddedEffect, needsActivation, OwnedAvatarEffect } from './useAvatarEffects';

const effect = (overrides: Partial<OwnedAvatarEffect> = {}): OwnedAvatarEffect => ({
    type: 10,
    subType: 0,
    duration: 3600,
    inactiveCount: 1,
    secondsLeft: 0,
    isPermanent: false,
    ...overrides
});

describe('mergeAddedEffect', () => {
    it('adds an effect the user does not own', () => {
        expect(mergeAddedEffect([], effect())).toEqual([effect()]);
    });

    it('adds a timed copy to the stock and keeps the running time', () => {
        const merged = mergeAddedEffect([effect({ inactiveCount: 2, secondsLeft: 120 })], effect());

        expect(merged[0]).toMatchObject({ inactiveCount: 3, secondsLeft: 120, isPermanent: false });
    });

    it('makes an owned timed effect permanent', () => {
        const merged = mergeAddedEffect([effect({ secondsLeft: 120 })], effect({ isPermanent: true, duration: 2147483647 }));

        expect(merged[0]).toMatchObject({ isPermanent: true, secondsLeft: 120, inactiveCount: 1 });
    });
});

describe('needsActivation', () => {
    it('starts the timer of a timed effect that is not running', () => {
        expect(needsActivation(effect({ secondsLeft: 0 }))).toBe(true);
    });

    it('leaves a running timed effect alone, so choosing it again does not refill its time', () => {
        expect(needsActivation(effect({ secondsLeft: 1200 }))).toBe(false);
    });

    it('still activates a permanent effect and an effect the list does not know yet', () => {
        expect(needsActivation(effect({ isPermanent: true, secondsLeft: 1200 }))).toBe(true);
        expect(needsActivation(undefined)).toBe(true);
    });
});
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser