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

Configure Feed

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

at v4 77 lines 2.4 kB view raw
1import { describe, it } from "@std/testing/bdd"; 2import { expect } from "@std/expect"; 3 4import { testWeb } from "@tests/common/index.ts"; 5 6describe("components/configurator/metadata", () => { 7 it("returns track unchanged when there are no children", async () => { 8 const result = await testWeb(async () => { 9 const { CLASS } = await import( 10 "~/components/configurator/metadata/element.js" 11 ); 12 13 const configurator = new CLASS(); 14 document.body.append(configurator); 15 await customElements.whenDefined(configurator.localName); 16 17 const track = { 18 $type: "sh.diffuse.output.track" as const, 19 id: "metadata-configurator-test-no-children", 20 uri: "local://test", 21 }; 22 23 const result = await configurator.patch(track); 24 return { sameId: result.id === track.id, hasTags: !!result.tags }; 25 }); 26 27 expect(result.sameId).toBe(true); 28 expect(result.hasTags).toBe(false); 29 }); 30 31 it("chains patches through children in sequence", async () => { 32 const result = await testWeb(async () => { 33 const HttpsInput = await import("~/components/input/https/element.js"); 34 const AudioFile = await import( 35 "~/components/metadata/audio-file/element.js" 36 ); 37 const { CLASS } = await import( 38 "~/components/configurator/metadata/element.js" 39 ); 40 41 const input = new HttpsInput.CLASS(); 42 input.id = "test-metadata-configurator-input"; 43 document.body.append(input); 44 45 const audioFile = new AudioFile.CLASS(); 46 audioFile.setAttribute( 47 "input-selector", 48 "#test-metadata-configurator-input", 49 ); 50 51 const configurator = new CLASS(); 52 configurator.append(audioFile); 53 document.body.append(configurator); 54 55 await customElements.whenDefined(input.localName); 56 await customElements.whenDefined(configurator.localName); 57 58 const blob = await fetch("/testing/sample/audio.mp3").then((r) => 59 r.blob() 60 ); 61 const blobUri = URL.createObjectURL(blob); 62 63 const track = { 64 $type: "sh.diffuse.output.track" as const, 65 id: "metadata-configurator-test-chain", 66 uri: blobUri, 67 }; 68 69 const patched = await configurator.patch(track); 70 URL.revokeObjectURL(blobUri); 71 72 return { title: patched.tags?.title ?? null }; 73 }); 74 75 expect(result.title).toBe("Mr. Sandman"); 76 }); 77});