mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 18:14:29 -07:00
Disallow redundant typecasts. (#15030)
This commit is contained in:
committed by
GitHub
parent
fcc3b2b5ec
commit
942bcfc61e
@@ -36,10 +36,9 @@ vi.mock('@lydell/node-pty', () => ({
|
||||
spawn: mockPtySpawn,
|
||||
}));
|
||||
vi.mock('node:child_process', async (importOriginal) => {
|
||||
const actual =
|
||||
(await importOriginal()) as typeof import('node:child_process');
|
||||
const actual = await importOriginal();
|
||||
return {
|
||||
...actual,
|
||||
...(actual as object),
|
||||
spawn: mockCpSpawn,
|
||||
};
|
||||
});
|
||||
@@ -90,7 +89,7 @@ const createMockSerializeTerminalToObjectReturnValue = (
|
||||
text: string | string[],
|
||||
): AnsiOutput => {
|
||||
const lines = Array.isArray(text) ? text : text.split('\n');
|
||||
const len = (shellExecutionConfig.terminalHeight ?? 24) as number;
|
||||
const len = shellExecutionConfig.terminalHeight ?? 24;
|
||||
const expected: AnsiOutput = Array.from({ length: len }, (_, i) => [
|
||||
{
|
||||
text: (lines[i] || '').trim(),
|
||||
@@ -108,7 +107,7 @@ const createMockSerializeTerminalToObjectReturnValue = (
|
||||
|
||||
const createExpectedAnsiOutput = (text: string | string[]): AnsiOutput => {
|
||||
const lines = Array.isArray(text) ? text : text.split('\n');
|
||||
const len = (shellExecutionConfig.terminalHeight ?? 24) as number;
|
||||
const len = shellExecutionConfig.terminalHeight ?? 24;
|
||||
const expected: AnsiOutput = Array.from({ length: len }, (_, i) => [
|
||||
{
|
||||
text: expect.stringMatching((lines[i] || '').trim()),
|
||||
@@ -419,7 +418,7 @@ describe('ShellExecutionService', () => {
|
||||
it('should write to the pty and trigger a render', async () => {
|
||||
vi.useFakeTimers();
|
||||
await simulateExecution('interactive-app', (pty) => {
|
||||
ShellExecutionService.writeToPty(pty.pid!, 'input');
|
||||
ShellExecutionService.writeToPty(pty.pid, 'input');
|
||||
pty.onExit.mock.calls[0][0]({ exitCode: 0, signal: null });
|
||||
});
|
||||
|
||||
@@ -434,7 +433,7 @@ describe('ShellExecutionService', () => {
|
||||
it('should resize the pty and the headless terminal', async () => {
|
||||
await simulateExecution('ls -l', (pty) => {
|
||||
pty.onData.mock.calls[0][0]('file1.txt\n');
|
||||
ShellExecutionService.resizePty(pty.pid!, 100, 40);
|
||||
ShellExecutionService.resizePty(pty.pid, 100, 40);
|
||||
pty.onExit.mock.calls[0][0]({ exitCode: 0, signal: null });
|
||||
});
|
||||
|
||||
@@ -448,7 +447,7 @@ describe('ShellExecutionService', () => {
|
||||
.mockReturnValue(false);
|
||||
|
||||
await simulateExecution('ls -l', (pty) => {
|
||||
ShellExecutionService.resizePty(pty.pid!, 100, 40);
|
||||
ShellExecutionService.resizePty(pty.pid, 100, 40);
|
||||
pty.onExit.mock.calls[0][0]({ exitCode: 0, signal: null });
|
||||
});
|
||||
|
||||
@@ -468,7 +467,7 @@ describe('ShellExecutionService', () => {
|
||||
// We don't expect this test to throw an error
|
||||
await expect(
|
||||
simulateExecution('ls -l', (pty) => {
|
||||
ShellExecutionService.resizePty(pty.pid!, 100, 40);
|
||||
ShellExecutionService.resizePty(pty.pid, 100, 40);
|
||||
pty.onExit.mock.calls[0][0]({ exitCode: 0, signal: null });
|
||||
}),
|
||||
).resolves.not.toThrow();
|
||||
@@ -484,7 +483,7 @@ describe('ShellExecutionService', () => {
|
||||
|
||||
await expect(
|
||||
simulateExecution('ls -l', (pty) => {
|
||||
ShellExecutionService.resizePty(pty.pid!, 100, 40);
|
||||
ShellExecutionService.resizePty(pty.pid, 100, 40);
|
||||
pty.onExit.mock.calls[0][0]({ exitCode: 0, signal: null });
|
||||
}),
|
||||
).rejects.toThrow('Some other error');
|
||||
@@ -493,7 +492,7 @@ describe('ShellExecutionService', () => {
|
||||
it('should scroll the headless terminal', async () => {
|
||||
await simulateExecution('ls -l', (pty) => {
|
||||
pty.onData.mock.calls[0][0]('file1.txt\n');
|
||||
ShellExecutionService.scrollPty(pty.pid!, 10);
|
||||
ShellExecutionService.scrollPty(pty.pid, 10);
|
||||
pty.onExit.mock.calls[0][0]({ exitCode: 0, signal: null });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user