mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Revert "Marking nowPlaying in smapi setPlayedSeconds handler so does not mark when sonos pre-caches a track (#57)" (#66)
This reverts commit c312778e13.
This commit is contained in:
@@ -3071,11 +3071,9 @@ describe("api", () => {
|
||||
function itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed,
|
||||
shouldMarkNowPlaying,
|
||||
}: {
|
||||
trackId: string;
|
||||
secondsPlayed: number;
|
||||
shouldMarkNowPlaying: boolean;
|
||||
}) {
|
||||
it("should scrobble", async () => {
|
||||
musicLibrary.scrobble.mockResolvedValue(true);
|
||||
@@ -3090,22 +3088,15 @@ describe("api", () => {
|
||||
expect(accessTokens.mint).toHaveBeenCalledWith(authToken);
|
||||
expect(musicLibrary.track).toHaveBeenCalledWith(trackId);
|
||||
expect(musicLibrary.scrobble).toHaveBeenCalledWith(trackId);
|
||||
if (shouldMarkNowPlaying) {
|
||||
expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId);
|
||||
} else {
|
||||
expect(musicLibrary.nowPlaying).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed,
|
||||
shouldMarkNowPlaying,
|
||||
}: {
|
||||
trackId: string;
|
||||
secondsPlayed: number;
|
||||
shouldMarkNowPlaying: boolean;
|
||||
}) {
|
||||
it("should scrobble", async () => {
|
||||
const result = await ws.setPlayedSecondsAsync({
|
||||
@@ -3118,11 +3109,6 @@ describe("api", () => {
|
||||
expect(accessTokens.mint).toHaveBeenCalledWith(authToken);
|
||||
expect(musicLibrary.track).toHaveBeenCalledWith(trackId);
|
||||
expect(musicLibrary.scrobble).not.toHaveBeenCalled();
|
||||
if (shouldMarkNowPlaying) {
|
||||
expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId);
|
||||
} else {
|
||||
expect(musicLibrary.nowPlaying).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3133,44 +3119,16 @@ describe("api", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("when the seconds played is 30 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 30,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is 30 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 30 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is > 30 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 90,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is > 30 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 90 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is < 30 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 29,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the seconds played is 1 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 1,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the seconds played is 0 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 0,
|
||||
shouldMarkNowPlaying: false,
|
||||
});
|
||||
describe("when the played length is < 30 seconds", () => {
|
||||
itShouldNotScroble({ trackId, secondsPlayed: 29 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3181,44 +3139,16 @@ describe("api", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("when the seconds played is 30 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 30,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is 30 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 30 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is > 30 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 90,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is > 30 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 90 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is < 30 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 29,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the seconds played is 1 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 1,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the seconds played is 0 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 0,
|
||||
shouldMarkNowPlaying: false,
|
||||
});
|
||||
describe("when the played length is < 30 seconds", () => {
|
||||
itShouldNotScroble({ trackId, secondsPlayed: 29 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3229,52 +3159,20 @@ describe("api", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("when the seconds played is 29 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 30,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is 29 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 30 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is > 29 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 30,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is > 29 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 30 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is 10 seconds", () => {
|
||||
itShouldScroble({
|
||||
trackId,
|
||||
secondsPlayed: 10,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
describe("when the played length is 10 seconds", () => {
|
||||
itShouldScroble({ trackId, secondsPlayed: 10 });
|
||||
});
|
||||
|
||||
describe("when the seconds played is < 10 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 9,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the seconds played is 1 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 1,
|
||||
shouldMarkNowPlaying: true,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the seconds played is 0 seconds", () => {
|
||||
itShouldNotScroble({
|
||||
trackId,
|
||||
secondsPlayed: 0,
|
||||
shouldMarkNowPlaying: false,
|
||||
});
|
||||
describe("when the played length is < 10 seconds", () => {
|
||||
itShouldNotScroble({ trackId, secondsPlayed: 9 });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3289,7 +3187,6 @@ describe("api", () => {
|
||||
expect(result[0]).toEqual({ setPlayedSecondsResult: null });
|
||||
expect(musicService.login).toHaveBeenCalledWith(authToken);
|
||||
expect(accessTokens.mint).toHaveBeenCalledWith(authToken);
|
||||
expect(musicLibrary.nowPlaying).not.toHaveBeenCalled();
|
||||
expect(musicLibrary.scrobble).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user