|
| 1 | +/** |
| 2 | + * Teleport |
| 3 | + * Copyright (C) 2024 Gravitational, Inc. |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Affero General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Affero General Public License |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +import { makeRuntimeSettings } from 'teleterm/mainProcess/fixtures/mocks'; |
| 20 | + |
| 21 | +import { getWindowsPty } from './windowsPty'; |
| 22 | + |
| 23 | +test.each([ |
| 24 | + { |
| 25 | + name: 'uses conpty on supported Windows version', |
| 26 | + platform: 'win32' as const, |
| 27 | + osVersion: '10.0.22621', |
| 28 | + terminalOptions: { windowsBackend: 'auto' as const }, |
| 29 | + expected: { useConpty: true, buildNumber: 22621 }, |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'uses winpty on unsupported Windows version', |
| 33 | + platform: 'win32' as const, |
| 34 | + osVersion: '10.0.18308', |
| 35 | + terminalOptions: { windowsBackend: 'auto' as const }, |
| 36 | + expected: { useConpty: false, buildNumber: 18308 }, |
| 37 | + }, |
| 38 | + { |
| 39 | + name: 'uses winpty when Windows version is supported, but conpty is disabled in options', |
| 40 | + platform: 'win32' as const, |
| 41 | + osVersion: '10.0.22621', |
| 42 | + terminalOptions: { windowsBackend: 'winpty' as const }, |
| 43 | + expected: { useConpty: false, buildNumber: 22621 }, |
| 44 | + }, |
| 45 | + { |
| 46 | + name: 'undefined on non-Windows OS', |
| 47 | + platform: 'darwin' as const, |
| 48 | + osVersion: '23.5.0', |
| 49 | + terminalOptions: { windowsBackend: 'auto' as const }, |
| 50 | + expected: undefined, |
| 51 | + }, |
| 52 | +])('$name', ({ platform, osVersion, terminalOptions, expected }) => { |
| 53 | + const pty = getWindowsPty( |
| 54 | + makeRuntimeSettings({ |
| 55 | + platform, |
| 56 | + osVersion, |
| 57 | + }), |
| 58 | + terminalOptions |
| 59 | + ); |
| 60 | + expect(pty).toEqual(expected); |
| 61 | +}); |
0 commit comments