···66import { PlayObject } from "../../../core/Atomic.js";
77import { UpstreamError } from "../../common/errors/UpstreamError.js";
8899-import { ListenbrainzApiClient, playToListenPayload } from "../../common/vendor/ListenbrainzApiClient.js";
99+import { ListenbrainzApiClient, playToListenPayload, listenResponseToPlay, listenPayloadToPlay } from "../../common/vendor/ListenbrainzApiClient.js";
1010import { ListenResponse } from '../../common/vendor/listenbrainz/interfaces.js';
1111import { ExpectedResults } from "../utils/interfaces.js";
1212import { withRequestInterception } from "../utils/networking.js";
···3333 describe('When user-submitted artist/track do NOT match MB mappings', function() {
3434 it('Uses user submitted values when no artist mappings', async function () {
3535 for(const test of noArtistMapping as unknown as LZTestFixture[]) {
3636- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
3636+ const play = listenResponseToPlay(test.data);
3737 assert.equal(play.data.track, test.expected.track);
3838 assert.sameDeepMembers(play.data.artists, test.expected.artists);
3939 }
···41414242 it('Uses user-submitted values when when either mapped track/artist do not match', async function () {
4343 for(const test of veryWrong as unknown as LZTestFixture[]) {
4444- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
4444+ const play = listenResponseToPlay(test.data);
4545 assert.equal(play.data.track, test.expected.track);
4646 assert.sameDeepMembers( play.data.artists, test.expected.artists);
4747 }
···49495050 it('Should extract additional artists from track name', async function () {
5151 for(const test of incorrectMultiArtistsTrackName as unknown as LZTestFixture[]) {
5252- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
5252+ const play = listenResponseToPlay(test.data);
5353 assert.equal(play.data.track, test.expected.track);
5454 assert.sameDeepMembers(play.data.artists, test.expected.artists);
5555 }
···61616262 it('Detects slightly different track names as equal', async function () {
6363 for(const test of slightlyDifferentNames as unknown as LZTestFixture[]) {
6464- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
6464+ const play = listenResponseToPlay(test.data);
6565 assert.equal(play.data.track, test.expected.track);
6666 assert.sameDeepMembers(play.data.artists, test.expected.artists);
6767 }
···69697070 it('Uses all mapped artists', async function () {
7171 for(const test of multiMappedArtistsWithSingleUserArtist as unknown as LZTestFixture[]) {
7272- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
7272+ const play = listenResponseToPlay(test.data);
7373 assert.equal(play.data.track, test.expected.track);
7474 assert.sameDeepMembers(play.data.artists, test.expected.artists);
7575 }
···77777878 it('Respects artists with joiner symbols in proper names', async function () {
7979 for(const test of artistWithProperJoiner as unknown as LZTestFixture[]) {
8080- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
8080+ const play = listenResponseToPlay(test.data);
8181 assert.equal(play.data.track, test.expected.track);
8282 assert.sameDeepMembers( play.data.artists, test.expected.artists);
8383 }
···85858686 it('Detects user-submitted artists have joiners', async function () {
8787 for(const test of multiArtistInArtistName as unknown as LZTestFixture[]) {
8888- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
8888+ const play = listenResponseToPlay(test.data);
8989 assert.equal(play.data.track, test.expected.track);
9090 assert.sameDeepMembers(play.data.artists, test.expected.artists);
9191 }
···93939494 it('Detects artists in user-submitted track', async function () {
9595 for(const test of multiArtistsInTrackName as unknown as LZTestFixture[]) {
9696- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
9696+ const play = listenResponseToPlay(test.data);
9797 assert.equal(play.data.track, test.expected.track);
9898 assert.sameDeepMembers( play.data.artists, test.expected.artists);
9999 }
···101101102102 it('Detects and uses normalized artist/track names', async function () {
103103 for(const test of normalizedValues as unknown as LZTestFixture[]) {
104104- const play = ListenbrainzApiClient.listenResponseToPlay(test.data);
104104+ const play = listenResponseToPlay(test.data);
105105 assert.equal(play.data.track, test.expected.track);
106106 assert.sameDeepMembers( play.data.artists, test.expected.artists);
107107 }
···164164165165 submitPayload.track_metadata.additional_info.artist_names = additionalArtists;
166166167167- const playFromPayload = ListenbrainzApiClient.listenPayloadToPlay(submitPayload);
167167+ const playFromPayload = listenPayloadToPlay(submitPayload);
168168169169 expect(playFromPayload.data.artists).to.be.eql(additionalArtists)
170170···179179180180 submitPayload.track_metadata.additional_info.artist_names = additionalArtists;
181181182182- const playFromPayload = ListenbrainzApiClient.listenPayloadToPlay(submitPayload);
182182+ const playFromPayload = listenPayloadToPlay(submitPayload);
183183184184 expect(playFromPayload.data.artists).to.be.eql(['Artist A', 'Artist B'])
185185