mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { transitionPluginTerminalConnectionState } from './usePluginTerminalSessionLifecycle.ts';
|
|
|
|
const connectedState = {
|
|
cwd: '/srv/old',
|
|
title: 'old backend',
|
|
cols: 120,
|
|
rows: 40,
|
|
alternateScreen: true,
|
|
};
|
|
|
|
test('disconnect clears connection-scoped terminal Provider metadata before publishing', () => {
|
|
assert.deepEqual(
|
|
transitionPluginTerminalConnectionState(connectedState, 'disconnected', true),
|
|
{
|
|
snapshotState: { cols: 120, rows: 40 },
|
|
everConnected: true,
|
|
eventType: 'disconnected',
|
|
},
|
|
);
|
|
});
|
|
|
|
test('reconnect clears stale backend metadata while retaining viewport dimensions', () => {
|
|
assert.deepEqual(
|
|
transitionPluginTerminalConnectionState(connectedState, 'connected', true),
|
|
{
|
|
snapshotState: { cols: 120, rows: 40 },
|
|
everConnected: true,
|
|
eventType: 'reconnected',
|
|
},
|
|
);
|
|
});
|
|
|
|
test('the initial connection preserves its initial cwd snapshot', () => {
|
|
assert.deepEqual(
|
|
transitionPluginTerminalConnectionState({ cwd: '/srv/initial' }, 'connected', false),
|
|
{
|
|
snapshotState: { cwd: '/srv/initial' },
|
|
everConnected: true,
|
|
eventType: 'connected',
|
|
},
|
|
);
|
|
});
|
|
|
|
test('a reconnecting transition clears stale metadata before any later disposal', () => {
|
|
assert.deepEqual(
|
|
transitionPluginTerminalConnectionState(connectedState, 'connecting', true),
|
|
{
|
|
snapshotState: { cols: 120, rows: 40 },
|
|
everConnected: true,
|
|
},
|
|
);
|
|
});
|
|
|
|
test('transition snapshots remain writable for later cwd and title updates', () => {
|
|
const transition = transitionPluginTerminalConnectionState(connectedState, 'connected', true);
|
|
transition.snapshotState.cwd = '/srv/new';
|
|
transition.snapshotState.title = 'new backend';
|
|
|
|
assert.deepEqual(transition.snapshotState, {
|
|
cols: 120,
|
|
rows: 40,
|
|
cwd: '/srv/new',
|
|
title: 'new backend',
|
|
});
|
|
});
|