test: expand markdown and post menu coverage

Adds focused regression coverage for quote previews, markdown link rendering, embed toggles, and desktop/mobile post-menu actions. It also fixes the undefined feed-state crash in use-state-string.ts and removes unnecessary runtime imports with import type.
This commit is contained in:
plebeius
2026-03-08 16:30:02 +08:00
parent 9444d3e01a
commit b2137c7f91
11 changed files with 1338 additions and 3 deletions
@@ -0,0 +1,44 @@
import * as React from 'react';
import { createElement } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import LoadingEllipsis from '../loading-ellipsis';
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
const act = (React as { act?: (cb: () => void | Promise<void>) => void | Promise<void> }).act as (cb: () => void | Promise<void>) => void | Promise<void>;
let container: HTMLDivElement;
let root: Root;
describe('LoadingEllipsis', () => {
beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
root = createRoot(container);
});
afterEach(() => {
act(() => root.unmount());
container.remove();
});
it('keeps the last word inside the nowrap span and preserves the prefix text', () => {
act(() => {
root.render(createElement(LoadingEllipsis, { string: 'Downloading board' }));
});
const spans = container.querySelectorAll('span');
expect(container.textContent).toBe('Downloading board');
expect(spans[1]?.textContent).toBe('board');
expect(spans[2]).toBeTruthy();
});
it('renders single-word strings without a leading space', () => {
act(() => {
root.render(createElement(LoadingEllipsis, { string: 'Loading' }));
});
expect(container.textContent).toBe('Loading');
expect(container.firstChild?.textContent).toBe('Loading');
});
});