Skip to content

Commit

Permalink
changed name of a fuction
Browse files Browse the repository at this point in the history
  • Loading branch information
justinasRm committed Sep 20, 2024
1 parent 42d1849 commit faf061c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions packages/sdk-tizen/src/__tests__/deviceManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
inquirerPrompt,
ExecOptionsPresets,
} from '@rnv/core';
import { listTizenTargets, launchTizenEmulator } from '../deviceManager';
import { listTizenTargets, launchTizenTarget } from '../deviceManager';
import { CLI_TIZEN_EMULATOR, CLI_SDB_TIZEN } from '../constants';

const ERROR_MSG = {
Expand Down Expand Up @@ -84,17 +84,17 @@ describe('listTizenTargets', () => {
});
});

describe('launchTizenEmulator', () => {
describe('launchTizenTarget', () => {
it('should launch the specified emulator by name', async () => {
const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' };
const ctx = { ...getContext(), ...mockContext };
createRnvContext(ctx);

(executeAsync as jest.Mock).mockResolvedValue(true);

const result = await launchTizenEmulator('emulatorName');
const result = await launchTizenTarget('emulatorName');

expect(logDefault).toHaveBeenCalledWith('launchTizenEmulator:emulatorName');
expect(logDefault).toHaveBeenCalledWith('launchTizenTarget:emulatorName');
expect(executeAsync).toHaveBeenCalledWith(
'tizen-emulator launch --name emulatorName',
ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY
Expand All @@ -109,7 +109,7 @@ describe('launchTizenEmulator', () => {
(execCLI as jest.Mock).mockResolvedValueOnce('emulator1\nemulator2').mockResolvedValueOnce('device1\ndevice2');
(inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' });
(executeAsync as jest.Mock).mockResolvedValue(true);
const result = await launchTizenEmulator(true);
const result = await launchTizenTarget(true);
expect(execCLI).toHaveBeenCalledWith(CLI_TIZEN_EMULATOR, 'list-vm');
expect(execCLI).toHaveBeenCalledWith(CLI_SDB_TIZEN, 'devices');
expect(inquirerPrompt).toHaveBeenCalledWith({
Expand All @@ -136,7 +136,7 @@ describe('launchTizenEmulator', () => {
);
(inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' });
(executeAsync as jest.Mock).mockResolvedValue(true);
const result = await launchTizenEmulator(true, true);
const result = await launchTizenTarget(true, true);
expect(inquirerPrompt).toHaveBeenCalledWith({
name: 'chosenEmulator',
type: 'list',
Expand All @@ -145,7 +145,7 @@ describe('launchTizenEmulator', () => {
});
expect(result).toBe(true);
});
it('should show real devices(same conditions as test above, just not passing 2nd param true to launchTizenEmulator) ', async () => {
it('should show real devices(same conditions as test above, just not passing 2nd param true to launchTizenTarget) ', async () => {
const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' };
const ctx = { ...getContext(), ...mockContext };
createRnvContext(ctx);
Expand All @@ -157,7 +157,7 @@ describe('launchTizenEmulator', () => {
);
(inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' });
(executeAsync as jest.Mock).mockResolvedValue(true);
const result = await launchTizenEmulator(true);
const result = await launchTizenTarget(true);
expect(inquirerPrompt).toHaveBeenCalledWith({
name: 'chosenEmulator',
type: 'list',
Expand All @@ -175,7 +175,7 @@ describe('launchTizenEmulator', () => {
(execCLI as jest.Mock).mockResolvedValueOnce('emulator1\nemulator2').mockResolvedValueOnce('device1\ndevice2');
(inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' });
(executeAsync as jest.Mock).mockResolvedValue(true);
const result = await launchTizenEmulator('unknownEmulator');
const result = await launchTizenTarget('unknownEmulator');
expect(logError).toHaveBeenCalledWith('The VM/device "unknownEmulator" does not exist.');
expect(execCLI).toHaveBeenCalledWith(CLI_TIZEN_EMULATOR, 'list-vm');
expect(execCLI).toHaveBeenCalledWith(CLI_SDB_TIZEN, 'devices');
Expand All @@ -197,11 +197,11 @@ describe('launchTizenEmulator', () => {
createRnvContext(ctx);

(executeAsync as jest.Mock).mockRejectedValueOnce(ERROR_MSG.ALREADY_RUNNING);
const result = await launchTizenEmulator('runningEmulator');
const result = await launchTizenTarget('runningEmulator');
expect(logError).toHaveBeenCalledWith('The VM/device "runningEmulator" is already running.');
expect(result).toBe(true);
});
it('should reject if no name is specified', async () => {
await expect(launchTizenEmulator('')).rejects.toEqual('No emulator -t target name specified!');
await expect(launchTizenTarget('')).rejects.toEqual('No emulator -t target name specified!');
});
});
18 changes: 9 additions & 9 deletions packages/sdk-tizen/src/deviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ const formatXMLObject = (
return {};
};

export const launchTizenEmulator = async (name: string | true, hideDevices?: boolean): Promise<boolean> => {
export const launchTizenTarget = async (name: string | true, hideDevices?: boolean): Promise<boolean> => {
const c = getContext();
logDefault(`launchTizenEmulator:${name}`);
logDefault(`launchTizenTarget:${name}`);
if (name === true) {
const emulators = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm');
const devices = await execCLI(CLI_SDB_TIZEN, 'devices');
Expand Down Expand Up @@ -120,7 +120,7 @@ export const launchTizenEmulator = async (name: string | true, hideDevices?: boo
if (typeof e === 'string') {
if (e.includes(ERROR_MSG.UNKNOWN_VM)) {
logError(`The VM/device "${name}" does not exist.`);
return launchTizenEmulator(true, hideDevices);
return launchTizenTarget(true, hideDevices);
}
if (e.includes(ERROR_MSG.ALREADY_RUNNING)) {
logError(`The VM/device "${name}" is already running.`);
Expand Down Expand Up @@ -389,7 +389,7 @@ export const runTizenSimOrDevice = async () => {
if (!tId) return Promise.reject(`Tizen platform requires "id" filed in platforms.tizen`);
const askForEmulator = async () => {
if (!target) {
launchTizenEmulator(true);
launchTizenTarget(true);
return;
}
const { startEmulator } = await inquirerPrompt({
Expand All @@ -406,15 +406,15 @@ export const runTizenSimOrDevice = async () => {
return;
}
try {
await launchTizenEmulator(defaultTarget);
await launchTizenTarget(defaultTarget);
deviceID = defaultTarget;
await _waitForEmulatorToBeReady(defaultTarget);
return continueLaunching();
} catch (e) {
logDebug(`askForEmulator:ERRROR: ${e}`);
try {
await execCLI(CLI_TIZEN_EMULATOR, `create -n ${defaultTarget} -p tv-samsung-5.0-x86`);
await launchTizenEmulator(defaultTarget);
await launchTizenTarget(defaultTarget);
deviceID = defaultTarget;
await _waitForEmulatorToBeReady(defaultTarget);
return continueLaunching();
Expand Down Expand Up @@ -445,7 +445,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
if (typeof e === 'string' && e.includes('No device matching')) {
if (target) {
isRunningEmulator = true;
await launchTizenEmulator(target);
await launchTizenTarget(target);
hasDevice = await _waitForEmulatorToBeReady(target);
} else {
return Promise.reject('Not target specified. (-t)');
Expand Down Expand Up @@ -475,7 +475,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}

if (target) {
isRunningEmulator = true;
await launchTizenEmulator(target);
await launchTizenTarget(target);
hasDevice = await _waitForEmulatorToBeReady(target);
} else {
return Promise.reject('Not target specified. (-t)');
Expand Down Expand Up @@ -522,7 +522,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
try {
// try to launch it, see if it's a emulator that's not started yet
isRunningEmulator = true;
await launchTizenEmulator(target);
await launchTizenTarget(target);
await _waitForEmulatorToBeReady(target);
deviceID = target;
return continueLaunching();
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-tizen/src/tasks/taskTargetLaunch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTask, RnvTaskName, RnvTaskOptions } from '@rnv/core';
import { getTargetWithOptionalPrompt } from '@rnv/sdk-utils';
import { checkAndConfigureTizenSdks, checkTizenSdk } from '../installer';
import { launchTizenEmulator } from '../deviceManager';
import { launchTizenTarget } from '../deviceManager';
import { SdkPlatforms } from '../constants';

export default createTask({
Expand All @@ -11,7 +11,7 @@ export default createTask({
await checkAndConfigureTizenSdks();
const target = await getTargetWithOptionalPrompt();
await checkTizenSdk();
return launchTizenEmulator(target, true);
return launchTizenTarget(target, true);
},
task: RnvTaskName.targetLaunch,
options: [RnvTaskOptions.target],
Expand Down

0 comments on commit faf061c

Please sign in to comment.