import { describe, expect, it } from "vitest";

import {
  consumePendingLogoutNavigation,
  setPendingLogoutNavigation,
} from "../logout-navigation";

describe("logout navigation", () => {
  it("consumes the pending destination only once", () => {
    setPendingLogoutNavigation("/characters/maya/splash");

    expect(consumePendingLogoutNavigation()).toBe(
      "/characters/maya/splash",
    );
    expect(consumePendingLogoutNavigation()).toBeNull();
  });

  it("keeps only the latest pending destination", () => {
    setPendingLogoutNavigation("/characters/elio/splash");
    setPendingLogoutNavigation("/characters/nayeli/splash");

    expect(consumePendingLogoutNavigation()).toBe(
      "/characters/nayeli/splash",
    );
  });
});
