Files
boos e0a5f57793 feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as
a monorepo subdirectory under desktop/. Source only — node_modules,
dist, Cargo target and the upstream .git history are excluded.

desktop/ keeps its own independent Cargo workspace (desktop/src-tauri
with crates/*); it is not part of the backend boosapi crate, so a
`cargo check` at the metapi root still compiles only the backend. Build
the desktop app from desktop/src-tauri per desktop/README.md.

Note: app icons are still placeholder assets pending the final BoosAPI
logo. The updater signing keys live outside the repo and are not
included.
2026-06-22 11:32:57 +08:00

42 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { collect, hasNode, paragraphHasCheckbox, textIncludes } from './midstate-utils'
describe('midstate-utils', () => {
it('collect finds nested nodes of a given type', () => {
const nodes = [
{ type: 'paragraph', children: [{ type: 'text', content: 'a' }] },
{ type: 'list', items: [{ type: 'list_item', children: [{ type: 'paragraph', children: [{ type: 'text', content: 'b' }] }] }] },
{ type: 'custom', children: [{ type: 'emphasis', children: [{ type: 'text', content: 'x' }] }] },
]
const paras = collect(nodes as any, 'paragraph')
expect(paras.length).toBeGreaterThanOrEqual(1)
const emph = collect(nodes as any, 'emphasis')
expect(emph.length).toBe(1)
})
it('hasNode returns true when node exists', () => {
const nodes = [{ type: 'a' }, { type: 'b' }, { type: 'c' }]
expect(hasNode(nodes as any, 'b')).toBe(true)
expect(hasNode(nodes as any, 'z')).toBe(false)
})
it('textIncludes works on simple structures', () => {
const nodes = [{ type: 'paragraph', children: [{ type: 'text', content: 'hello world' }] }]
expect(textIncludes(nodes as any, 'hello')).toBe(true)
expect(textIncludes(nodes as any, 'bye')).toBe(false)
})
it('textIncludes supports RegExp matching', () => {
const nodes = [{ type: 'paragraph', children: [{ type: 'text', content: 'Hello WORLD' }] }]
expect(textIncludes(nodes as any, /WORLD$/i)).toBe(true)
expect(textIncludes(nodes as any, /nope/)).toBe(false)
})
it('paragraphHasCheckbox detects checkbox children', () => {
const p = { type: 'paragraph', children: [{ type: 'checkbox', checked: true }, { type: 'text', content: 'hi' }] }
expect(paragraphHasCheckbox([p] as any)).toBe(true)
const p2 = { type: 'paragraph', children: [{ type: 'text', content: 'nope' }] }
expect(paragraphHasCheckbox([p2] as any)).toBe(false)
})
})