5180 fichiers 38.5 Mo 0 téléchargements 270 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / hooks / soundboard / soundboardManifest.test.ts
soundboardManifest.test.ts 1.7 Ko Télécharger le fichier
import { describe, expect, it } from 'vitest';
import { normalizeSoundboardManifest } from './soundboardManifest';
import { soundboardPlayOptions } from './soundboardPresentation';

const manifestOf = (...pads: Record<string, unknown>[]) =>
    normalizeSoundboardManifest({ soundboard: pads.map((pad) => ({ classname: 'bell', file: 'bell.ogg', ...pad })) }).byClassname.get('bell');

describe('soundboard manifest group and gain', () => {
    it('reads the group and the gain of a pad', () => {
        expect(manifestOf({ group: 'Bells', gain: 0.5 })).toMatchObject({ group: 'bells', gain: 0.5 });
    });

    it('leaves a pad without a group and at full level when the manifest says nothing', () => {
        expect(manifestOf({})).toMatchObject({ group: '', gain: 1 });
    });

    it('ignores a group that is not a plain name and a gain outside the range', () => {
        expect(manifestOf({ group: 'not a name!', gain: 0 })).toMatchObject({ group: '', gain: 1 });
        expect(manifestOf({ group: 7, gain: 3 })).toMatchObject({ group: '', gain: 1 });
        expect(manifestOf({ gain: '0.5' })).toMatchObject({ gain: 1 });
    });
});

describe('soundboard play options', () => {
    it('hands the group and the gain to the sound manager', () => {
        expect(soundboardPlayOptions({ group: 'bells', gain: 0.5 })).toEqual({ group: 'bells', gain: 0.5 });
    });

    it('reports an empty group as none and a pad that is unknown as no options', () => {
        expect(soundboardPlayOptions({ group: '', gain: 1 })).toEqual({ group: undefined, gain: 1 });
        expect(soundboardPlayOptions(undefined)).toBeUndefined();
        expect(soundboardPlayOptions(null)).toBeUndefined();
    });
});
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