Support customizing emulator port (#383)

* Add port parameter

* Fix a typo in test description

* Fix avd not being started with correct port

* Fix wrong port being used to kill an emulator if there was an exception
This commit is contained in:
Kamil Bąk
2024-07-02 14:42:44 +02:00
committed by GitHub
parent ca77a1081f
commit 4b0628e9f8
10 changed files with 115 additions and 32 deletions
+28
View File
@@ -1,4 +1,5 @@
import * as validator from '../src/input-validator';
import { MAX_PORT, MIN_PORT } from '../src/input-validator';
describe('api-level validator tests', () => {
it('Throws if api-level is not a number', () => {
@@ -172,6 +173,33 @@ describe('force-avd-creation validator tests', () => {
});
});
describe('emulator-port validator tests', () => {
it('Validates if emulator-port is even and in range', () => {
const func = () => {
validator.checkPort(5554);
};
expect(func).not.toThrow();
});
it('Throws if emulator-port is lower than MIN_PORT', () => {
const func = () => {
validator.checkPort(MIN_PORT - 2);
};
expect(func).toThrow();
});
it('Throws if emulator-port is higher than MAX_PORT', () => {
const func = () => {
validator.checkPort(MAX_PORT + 2);
};
expect(func).toThrow();
});
it('Throws if emulator-port is odd', () => {
const func = () => {
validator.checkPort(5555);
};
expect(func).toThrow();
});
});
describe('disable-animations validator tests', () => {
it('Throws if disable-animations is not a boolean', () => {
const func = () => {