A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

test: queue engine uses shared worker

+55 -3
+10
src/testing/sample/tracks.js
··· 11 11 uri: "http://example.com/audio-a.mp3", 12 12 }; 13 13 14 + /** 15 + * @type {Track} 16 + */ 17 + const trackB = { 18 + $type: "sh.diffuse.output.tracks", 19 + id: "sample-b", 20 + uri: "http://example.com/audio-b.mp3", 21 + }; 22 + 14 23 export const tracks = [ 15 24 trackA, 25 + trackB, 16 26 ];
+45 -3
tests/components/engine/queue/test.ts
··· 20 20 return engine.future(); 21 21 }); 22 22 23 - expect(items.map((i) => i.id).join("/")).toBe( 24 - tracks.map((t) => t.id).join("/"), 25 - ); 23 + const futureIds = items.map((i) => i.id).join("/"); 24 + const sampleIds = tracks.map((t) => t.id).join("/"); 25 + 26 + expect(futureIds).toEqual(sampleIds); 26 27 }); 27 28 28 29 it("pools + fills tracks and shifts the queue", async () => { ··· 39 40 await engine.shift(); 40 41 41 42 return engine.now(); 43 + }); 44 + 45 + expect(item?.id).toBe(tracks[0].id); 46 + }); 47 + 48 + it("[shared worker] adds tracks and shifts + unshifts the queue", async () => { 49 + const item = await testWeb(async () => { 50 + const QueueEngine = await import("@components/engine/queue/element.js"); 51 + const engine = new QueueEngine.CLASS(); 52 + engine.setAttribute("group", "tests"); 53 + 54 + document.body.append(engine); 55 + 56 + const { tracks } = await import("@src/testing/sample/tracks.js"); 57 + 58 + await engine.add({ tracks }); 59 + await engine.shift(); 60 + await engine.shift(); 61 + await engine.unshift(); 62 + 63 + return engine.now(); 64 + }); 65 + 66 + expect(item?.id).toBe(tracks[0].id); 67 + }); 68 + 69 + it("[shared worker] has the correct past", async () => { 70 + const item = await testWeb(async () => { 71 + const QueueEngine = await import("@components/engine/queue/element.js"); 72 + const engine = new QueueEngine.CLASS(); 73 + engine.setAttribute("group", "tests"); 74 + 75 + document.body.append(engine); 76 + 77 + const { tracks } = await import("@src/testing/sample/tracks.js"); 78 + 79 + await engine.add({ tracks }); 80 + await engine.shift(); 81 + await engine.shift(); 82 + 83 + return engine.past()[0]; 42 84 }); 43 85 44 86 expect(item?.id).toBe(tracks[0].id);