1import { readFileSync } from 'node:fs'; 2import { describe, expect, it } from 'vitest'; 3import { SAMPLE_EXTENSIONS, sampleMap } from './sampleMap.mjs'; 4 5describe('sampleMap', () => { 6 it('lists each sound folder, sorted, with urls relative to _base', () => { 7 expect( 8 sampleMap([ 9 ['../../samples/jeff/b.wav', '/@fs/r/samples/jeff/b.wav?import'], 10 ['../../samples/jeff/a.mp3', '/@fs/r/samples/jeff/a.mp3'], 11 ['../../samples/hey/hey.ogg', '/_astro/hey.123.ogg'], 12 ]), 13 ).toEqual({ 14 _base: '/', 15 hey: ['_astro/hey.123.ogg'], 16 jeff: ['@fs/r/samples/jeff/a.mp3', '@fs/r/samples/jeff/b.wav'], 17 }); 18 }); 19 20 it("names the same extensions as the site's glob", () => { 21 const route = readFileSync(new URL('../pages/jev-samples/strudel.json.js', import.meta.url), 'utf8'); 22 const glob = route.match(/samples\/\*\/\*\.\{([^}]*)\}/)?.[1]; 23 expect(glob?.split(',')).toEqual(SAMPLE_EXTENSIONS); 24 }); 25});