Files
faunosteo/apps/app/tests/unit/anatomy.svgLoader.test.ts
T
bchanot 8673475293 chore(workspace): move the app to apps/app under a pnpm workspace (step 2)
144 files moved with git mv (pure renames). Root package.json delegates
dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and
pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager,
root devDependency, engine-strict). Dockerfile builds @faunosteo/app on
node:24-alpine and copies apps/app/dist; nginx and runtime config
unchanged. CI workflow for Gitea Actions. packages/ reserved (README only).
Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan.
271/271 tests, typecheck, lint, build green from the root.
2026-10-08 21:51:13 +02:00

24 lines
769 B
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest'
import { loadSvg } from '@/anatomy/svgLoader'
const SVG = '<svg xmlns="http://www.w3.org/2000/svg"><g data-anno-id="x"/></svg>'
describe('loadSvg', () => {
beforeEach(() => {
vi.stubGlobal('fetch', vi.fn(async () => ({
ok: true,
text: async () => SVG,
})) as unknown as typeof fetch)
})
it('returns an SVGSVGElement', async () => {
const root = await loadSvg('/whatever.svg')
expect(root.tagName.toLowerCase()).toBe('svg')
})
it('throws on non-ok response', async () => {
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: false, status: 404, text: async () => '' })) as unknown as typeof fetch)
await expect(loadSvg('/missing.svg')).rejects.toThrow()
})
})