e0a5f57793
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.
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { parseImageToken } from '../../packages/markdown-parser/src/parser/inline-parsers/image-parser'
|
|
|
|
// Minimal token-like shapes used by parser (only include fields used by parser)
|
|
function makeChildImageToken() {
|
|
return {
|
|
type: 'image',
|
|
tag: 'img',
|
|
attrs: [
|
|
['src', 'https://example.com/vue.png'],
|
|
['alt', ''],
|
|
['title', 'Vue Logo'],
|
|
],
|
|
content: 'Vue Logo',
|
|
children: [
|
|
{
|
|
type: 'text',
|
|
content: 'Vue Logo',
|
|
},
|
|
],
|
|
} as unknown as any
|
|
}
|
|
|
|
function makeOuterInlineToken() {
|
|
return {
|
|
type: 'inline',
|
|
tag: '',
|
|
attrs: null,
|
|
content: '',
|
|
children: [makeChildImageToken()],
|
|
} as unknown as any
|
|
}
|
|
|
|
describe('image-parser', () => {
|
|
it('falls back to child attrs or children content when attrs.alt is empty', () => {
|
|
const outer = makeOuterInlineToken()
|
|
const node = parseImageToken(outer as any)
|
|
expect(node.src).toBe('https://example.com/vue.png')
|
|
expect(node.title).toBe('Vue Logo')
|
|
// alt should be taken from token.content/child when attrs.alt is empty
|
|
expect(node.alt).toBe('Vue Logo')
|
|
})
|
|
|
|
it('uses child text when attrs.alt and parent content are empty', () => {
|
|
const child = makeChildImageToken()
|
|
// make the child have empty alt attr and parent content empty
|
|
child.attrs = [
|
|
['src', 'https://example.com/vue.png'],
|
|
['alt', ''],
|
|
['title', 'Vue Logo'],
|
|
]
|
|
child.content = ''
|
|
child.children = [
|
|
{
|
|
type: 'text',
|
|
content: 'Child Alt Text',
|
|
},
|
|
]
|
|
|
|
const outer = {
|
|
type: 'inline',
|
|
tag: '',
|
|
attrs: null,
|
|
content: '',
|
|
children: [child],
|
|
} as unknown as any
|
|
|
|
const node = parseImageToken(outer as any)
|
|
expect(node.src).toBe('https://example.com/vue.png')
|
|
expect(node.title).toBe('Vue Logo')
|
|
// alt should be taken from the inner child's text content
|
|
expect(node.alt).toBe('Child Alt Text')
|
|
})
|
|
})
|