mirror of
https://github.com/Quad4-Software/MeshChatX.git
synced 2026-08-18 09:49:09 -04:00
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
// SPDX-License-Identifier: 0BSD
|
|
|
|
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
|
|
import {
|
|
dismissLanBindNoAuthBanner,
|
|
isLanBindNoAuthBannerDismissed,
|
|
LAN_BIND_NO_AUTH_BANNER_DISMISSED_KEY,
|
|
shouldShowLanBindNoAuthBanner,
|
|
} from "@/js/lanBindWarning.js";
|
|
|
|
describe("shouldShowLanBindNoAuthBanner", () => {
|
|
const lanNoAuth = {
|
|
isElectron: false,
|
|
isAndroid: false,
|
|
authEnabled: false,
|
|
isLoopbackBind: false,
|
|
routeName: "messages",
|
|
dismissed: false,
|
|
};
|
|
|
|
beforeEach(() => {
|
|
localStorage.removeItem(LAN_BIND_NO_AUTH_BANNER_DISMISSED_KEY);
|
|
});
|
|
|
|
afterEach(() => {
|
|
localStorage.removeItem(LAN_BIND_NO_AUTH_BANNER_DISMISSED_KEY);
|
|
});
|
|
|
|
it("shows for browser LAN bind without auth", () => {
|
|
expect(shouldShowLanBindNoAuthBanner(lanNoAuth)).toBe(true);
|
|
});
|
|
|
|
it("hides on electron, android, loopback, auth, or auth route", () => {
|
|
expect(shouldShowLanBindNoAuthBanner({ ...lanNoAuth, isElectron: true })).toBe(false);
|
|
expect(shouldShowLanBindNoAuthBanner({ ...lanNoAuth, isAndroid: true })).toBe(false);
|
|
expect(shouldShowLanBindNoAuthBanner({ ...lanNoAuth, isLoopbackBind: true })).toBe(false);
|
|
expect(shouldShowLanBindNoAuthBanner({ ...lanNoAuth, authEnabled: true })).toBe(false);
|
|
expect(shouldShowLanBindNoAuthBanner({ ...lanNoAuth, routeName: "auth" })).toBe(false);
|
|
});
|
|
|
|
it("stays hidden after dismiss is persisted", () => {
|
|
dismissLanBindNoAuthBanner();
|
|
expect(isLanBindNoAuthBannerDismissed()).toBe(true);
|
|
expect(shouldShowLanBindNoAuthBanner(lanNoAuth)).toBe(false);
|
|
expect(shouldShowLanBindNoAuthBanner({ ...lanNoAuth, dismissed: true })).toBe(false);
|
|
});
|
|
});
|