This commit is contained in:
@@ -123,3 +123,38 @@ describe('terminal state reconciliation', () => {
|
||||
expect(useTerminalStore.getState().buffers.size).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('default terminal tab labels', () => {
|
||||
afterEach(() => useTerminalStore.getState().clearAll());
|
||||
|
||||
const labels = () =>
|
||||
useTerminalStore.getState().getDirectoryState('/repo')!.tabs.map((tab) => tab.label);
|
||||
|
||||
// Regression for https://github.com/openchamber/openchamber/issues/2718
|
||||
test('does not reuse the number of a closed tab', () => {
|
||||
const first = setup();
|
||||
useTerminalStore.getState().createTab('/repo');
|
||||
expect(labels()).toEqual(['Terminal', 'Terminal 2']);
|
||||
|
||||
useTerminalStore.getState().closeTab('/repo', first);
|
||||
useTerminalStore.getState().createTab('/repo');
|
||||
|
||||
expect(labels()).toEqual(['Terminal 2', 'Terminal 3']);
|
||||
});
|
||||
|
||||
test('numbers past a user-renamed "Terminal N" label instead of duplicating it', () => {
|
||||
const first = setup();
|
||||
useTerminalStore.getState().setTabLabel('/repo', first, 'Terminal 5');
|
||||
useTerminalStore.getState().createTab('/repo');
|
||||
|
||||
expect(labels()).toEqual(['Terminal 5', 'Terminal 6']);
|
||||
});
|
||||
|
||||
test('ignores custom labels and starts over at "Terminal" when no default-labeled tabs remain', () => {
|
||||
const first = setup();
|
||||
useTerminalStore.getState().setTabLabel('/repo', first, 'build');
|
||||
useTerminalStore.getState().createTab('/repo');
|
||||
|
||||
expect(labels()).toEqual(['build', 'Terminal']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user