- music landing: diverse per-genre album sliders (online counts / offline wide-probe fallback) and home-screen library shortcuts - add ArtistLinks component and shared navigation/genreDiversity utils - player/playback-mode refinements across Rust and frontend
36 lines
1008 B
TypeScript
36 lines
1008 B
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { navigateBack } from "./navigation";
|
|
|
|
const goto = vi.fn();
|
|
vi.mock("$app/navigation", () => ({
|
|
goto: (...args: unknown[]) => goto(...args),
|
|
}));
|
|
|
|
describe("navigateBack", () => {
|
|
beforeEach(() => {
|
|
goto.mockClear();
|
|
});
|
|
|
|
it("pops real history when there is in-app history to go back to", () => {
|
|
const back = vi.fn();
|
|
vi.spyOn(history, "back").mockImplementation(back);
|
|
vi.spyOn(history, "length", "get").mockReturnValue(3);
|
|
|
|
navigateBack("/library");
|
|
|
|
expect(back).toHaveBeenCalledOnce();
|
|
expect(goto).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("falls back to the given path on a fresh deep-link (no history)", () => {
|
|
const back = vi.fn();
|
|
vi.spyOn(history, "back").mockImplementation(back);
|
|
vi.spyOn(history, "length", "get").mockReturnValue(1);
|
|
|
|
navigateBack("/library/music");
|
|
|
|
expect(goto).toHaveBeenCalledWith("/library/music");
|
|
expect(back).not.toHaveBeenCalled();
|
|
});
|
|
});
|