1import { describe, expect, it } from 'vitest'; 2import { samplesIn } from './preload.mjs'; 3 4describe('preload', () => { 5 const banks = { jeff: ['j.mp3'], hh27: ['a.wav', 'b.wav'], tr909_bd: ['bd.wav'] }; 6 const hap = (value, at = 0) => ({ value, whole: { begin: at } }); 7 8 it('finds every sample bank and variant the haps play, once each, with when it is first heard', () => { 9 const haps = [ 10 hap({ s: 'jeff' }, 9), 11 hap({ s: 'jeff', gain: 1.2 }, 5), 12 hap({ s: 'hh27', n: 1 }), 13 hap({ s: 'bd', bank: 'tr909' }), 14 hap({ s: 'sawtooth', note: 'c3' }), 15 hap(0.5), 16 ]; 17 expect(samplesIn(haps, banks)).toEqual([ 18 { s: 'jeff', n: 0, at: 5 }, 19 { s: 'hh27', n: 1, at: 0 }, 20 { s: 'tr909_bd', n: 0, at: 0 }, 21 ]); 22 }); 23});