forked from
tokono.ma/diffuse
A music player that connects to your cloud/distributed storage.
1import { describe, it } from "@std/testing/bdd";
2import { expect } from "@std/expect";
3
4import { testWeb } from "@tests/common/index.ts";
5
6describe("components/configurator/artwork", () => {
7 it("returns null when there are no children", async () => {
8 const result = await testWeb(async () => {
9 const { CLASS } = await import(
10 "~/components/configurator/artwork/element.js"
11 );
12
13 const configurator = new CLASS();
14 document.body.append(configurator);
15 await customElements.whenDefined(configurator.localName);
16
17 return configurator.get({
18 $type: "sh.diffuse.output.track" as const,
19 id: "artwork-configurator-test",
20 uri: "local://test",
21 });
22 });
23
24 expect(result).toBe(null);
25 });
26
27 it("returns the result of the first child that returns non-null", async () => {
28 const result = await testWeb(async () => {
29 const { CLASS } = await import(
30 "~/components/configurator/artwork/element.js"
31 );
32 const MusicBrainz = await import(
33 "~/components/artwork/musicbrainz/element.js"
34 );
35 const LastFm = await import("~/components/artwork/last.fm/element.js");
36
37 const configurator = new CLASS();
38 configurator.append(new MusicBrainz.CLASS(), new LastFm.CLASS());
39 document.body.append(configurator);
40 await customElements.whenDefined(configurator.localName);
41
42 // Track has no artist or album — both components return null
43 return configurator.get({
44 $type: "sh.diffuse.output.track" as const,
45 id: "artwork-configurator-test",
46 uri: "local://test",
47 });
48 });
49
50 expect(result).toBe(null);
51 });
52});