Files
Netcatty/components/ui/portal-container.test.tsx
T
Ryanisgoodandbincxz 6cfd319e3f feat: 在终端主机列表中新增和编辑主机 (#2363)
* docs: design terminal host management

* feat: add work-surface host editor state

* feat: add work-surface host editor layer

* feat: add host creation and edit menu actions

* feat: expose host management from terminal tree

* feat: edit hosts without leaving terminal

* fix: keep host editor subpanels interactive

* fix: keep terminal host toolbar unchanged

* chore: exclude internal design notes from PR

* fix: preserve terminal host editor state

* fix: harden terminal host editor interactions

* fix: fully hide inactive host editor

---------

Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-07-21 16:51:03 +08:00

30 lines
1.0 KiB
TypeScript

import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { PortalContainerProvider, usePortalContainer } from './portal-container';
test('portal container is available to nested editor controls', () => {
const marker = {} as HTMLElement;
const Probe = () => <span>{usePortalContainer() === marker ? 'inside' : 'outside'}</span>;
assert.equal(
renderToStaticMarkup(
<PortalContainerProvider container={marker}>
<Probe />
</PortalContainerProvider>,
),
'<span>inside</span>',
);
});
test('editor dropdown primitives use the scoped portal container', () => {
for (const file of ['popover.tsx', 'select.tsx', 'tooltip.tsx']) {
const source = readFileSync(new URL(`./${file}`, import.meta.url), 'utf8');
assert.match(source, /usePortalContainer\(\)/);
assert.match(source, /Portal container=\{portalContainer \?\? undefined\}/);
}
});