Files
orca/src/main/runtime/windows-default-route-interfaces.test.ts
T
OrcaWinandOrcaWin c3939ebf0e fix(mobile): allow reachable Hyper-V pairing addresses (#13107)
* fix(mobile): allow reachable Hyper-V pairing addresses

* fix(mobile): keep host-local Hyper-V addresses filtered

* fix(mobile): preserve explicit address on empty refresh

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-08-07 20:37:47 -07:00

49 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import {
getWindowsDefaultRouteInterfaceNames,
type WindowsDefaultRouteEnvironment
} from './windows-default-route-interfaces'
function environment(
runPowerShell: WindowsDefaultRouteEnvironment['runPowerShell'],
platform: NodeJS.Platform = 'win32'
): WindowsDefaultRouteEnvironment {
return { platform, systemRoot: 'C:\\Windows', runPowerShell }
}
describe('getWindowsDefaultRouteInterfaceNames', () => {
it('returns active IPv4 and IPv6 default-route interface aliases', async () => {
const runPowerShell = vi.fn().mockResolvedValue('["vEthernet (Production LAN)","Ethernet"]')
await expect(getWindowsDefaultRouteInterfaceNames(environment(runPowerShell))).resolves.toEqual(
new Set(['vEthernet (Production LAN)', 'Ethernet'])
)
const script = runPowerShell.mock.calls[0]![0] as string
expect(runPowerShell.mock.calls[0]![1]).toBe(3_000)
expect(script).toContain("$ProgressPreference = 'SilentlyContinue'")
expect(script).toContain("$_.State -eq 'Alive'")
expect(script).toContain("$_.DestinationPrefix -eq '0.0.0.0/0'")
expect(script).toContain("$_.DestinationPrefix -eq '::/0'")
})
it('returns unknown when route inspection fails or emits malformed data', async () => {
await expect(
getWindowsDefaultRouteInterfaceNames(
environment(vi.fn().mockRejectedValue(new Error('managed host')))
)
).resolves.toBeNull()
await expect(
getWindowsDefaultRouteInterfaceNames(environment(vi.fn().mockResolvedValue('"Ethernet"')))
).resolves.toBeNull()
})
it('does not inspect routes outside Windows', async () => {
const runPowerShell = vi.fn()
await expect(
getWindowsDefaultRouteInterfaceNames(environment(runPowerShell, 'linux'))
).resolves.toEqual(new Set())
expect(runPowerShell).not.toHaveBeenCalled()
})
})