BlueSky & more on desktop lazurite.stormlightlabs.org/
tauri rust typescript bluesky appview atproto solid
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 57 lines 1.7 kB view raw
1import { AppTestProviders } from "$/test/providers"; 2import { fireEvent, render, screen } from "@solidjs/testing-library"; 3import { describe, expect, it, vi } from "vitest"; 4import { AccountSwitcher } from "../AccountSwitcher"; 5 6const ACCOUNT = { 7 active: false, 8 avatar: "https://example.com/avatar.png", 9 did: "did:plc:alice", 10 handle: "alice.test", 11 pdsUrl: "https://pds.example.com", 12} as const; 13 14describe("AccountSwitcher", () => { 15 it("renders the stored account when no active session exists", () => { 16 render(() => ( 17 <AppTestProviders 18 session={{ 19 accounts: [ACCOUNT], 20 activeAccount: null, 21 activeSession: null, 22 hasSession: false, 23 primaryAccount: ACCOUNT, 24 }}> 25 <AccountSwitcher /> 26 </AppTestProviders> 27 )); 28 29 expect(screen.getByText("alice.test")).toBeInTheDocument(); 30 expect(screen.getByText("Session expired")).toBeInTheDocument(); 31 }); 32 33 it("closes the menu on outside pointerdown instead of toggling", () => { 34 const closeSwitcher = vi.fn(); 35 const toggleSwitcher = vi.fn(); 36 37 render(() => ( 38 <> 39 <AppTestProviders 40 session={{ 41 accounts: [ACCOUNT], 42 activeAccount: ACCOUNT, 43 activeSession: { did: ACCOUNT.did, handle: ACCOUNT.handle }, 44 }} 45 shell={{ closeSwitcher, showSwitcher: true, toggleSwitcher }}> 46 <AccountSwitcher /> 47 </AppTestProviders> 48 <div data-testid="outside">outside</div> 49 </> 50 )); 51 52 fireEvent.pointerDown(screen.getByTestId("outside")); 53 54 expect(closeSwitcher).toHaveBeenCalledTimes(1); 55 expect(toggleSwitcher).not.toHaveBeenCalled(); 56 }); 57});