Skip to content

Commit 53d1f7e

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/uuid-deprecation
2 parents 3a28afd + ee2b2f1 commit 53d1f7e

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

lib/common/test/unit-tests/mobile/android-emulator-service.ts

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function createTestInjector() {
2323
testInjector.register("utils", {
2424
getMilliSecondsTimeout: () => ({}),
2525
});
26+
testInjector.register("userSettingsService", {
27+
getSettingValue: () => Promise.resolve(null),
28+
});
2629

2730
return testInjector;
2831
}
@@ -70,14 +73,14 @@ describe("androidEmulatorService", () => {
7073
const testInjector = createTestInjector();
7174
androidEmulatorServices = testInjector.resolve("androidEmulatorServices");
7275
androidVirtualDeviceService = testInjector.resolve(
73-
"androidVirtualDeviceService"
76+
"androidVirtualDeviceService",
7477
);
7578
androidGenymotionService = testInjector.resolve("androidGenymotionService");
7679
});
7780

7881
function mockGetEmulatorImages(
7982
avds: Mobile.IEmulatorImagesOutput,
80-
genies: Mobile.IEmulatorImagesOutput
83+
genies: Mobile.IEmulatorImagesOutput,
8184
) {
8285
androidVirtualDeviceService.getEmulatorImages = () => Promise.resolve(avds);
8386
androidGenymotionService.getEmulatorImages = () => Promise.resolve(genies);
@@ -94,7 +97,7 @@ describe("androidEmulatorService", () => {
9497
it("should return [] when there are no emulators are available", async () => {
9598
mockGetEmulatorImages(
9699
{ devices: [], errors: [] },
97-
{ devices: [], errors: [] }
100+
{ devices: [], errors: [] },
98101
);
99102
const output = await androidEmulatorServices.getEmulatorImages();
100103
assert.deepStrictEqual(output.devices, []);
@@ -103,7 +106,7 @@ describe("androidEmulatorService", () => {
103106
it("should return avd emulators when only avd emulators are available", async () => {
104107
mockGetEmulatorImages(
105108
{ devices: [avdEmulator], errors: [] },
106-
{ devices: [], errors: [] }
109+
{ devices: [], errors: [] },
107110
);
108111
const output = await androidEmulatorServices.getEmulatorImages();
109112
assert.deepStrictEqual(output.devices, [avdEmulator]);
@@ -112,7 +115,7 @@ describe("androidEmulatorService", () => {
112115
it("should return geny emulators when only geny emulators are available", async () => {
113116
mockGetEmulatorImages(
114117
{ devices: [], errors: [] },
115-
{ devices: [genyEmulator], errors: [] }
118+
{ devices: [genyEmulator], errors: [] },
116119
);
117120
const output = await androidEmulatorServices.getEmulatorImages();
118121
assert.deepStrictEqual(output.devices, [genyEmulator]);
@@ -121,19 +124,19 @@ describe("androidEmulatorService", () => {
121124
it("should return avd and geny emulators when avd and geny emulators are available", async () => {
122125
mockGetEmulatorImages(
123126
{ devices: [avdEmulator], errors: [] },
124-
{ devices: [genyEmulator], errors: [] }
127+
{ devices: [genyEmulator], errors: [] },
125128
);
126129
const output = await androidEmulatorServices.getEmulatorImages();
127130
assert.deepStrictEqual(
128131
output.devices,
129-
[avdEmulator].concat([genyEmulator])
132+
[avdEmulator].concat([genyEmulator]),
130133
);
131134
assert.deepStrictEqual(output.errors, []);
132135
});
133136
it("should return an error when avd error is thrown", async () => {
134137
mockGetEmulatorImages(
135138
{ devices: [], errors: [mockError] },
136-
{ devices: [], errors: [] }
139+
{ devices: [], errors: [] },
137140
);
138141
const output = await androidEmulatorServices.getEmulatorImages();
139142
assert.deepStrictEqual(output.devices, []);
@@ -142,7 +145,7 @@ describe("androidEmulatorService", () => {
142145
it("should return an error when geny error is thrown", async () => {
143146
mockGetEmulatorImages(
144147
{ devices: [], errors: [] },
145-
{ devices: [], errors: [mockError] }
148+
{ devices: [], errors: [mockError] },
146149
);
147150
const output = await androidEmulatorServices.getEmulatorImages();
148151
assert.deepStrictEqual(output.devices, []);
@@ -151,7 +154,7 @@ describe("androidEmulatorService", () => {
151154
it("should return an error when avd and geny errors are thrown", async () => {
152155
mockGetEmulatorImages(
153156
{ devices: [], errors: [mockError] },
154-
{ devices: [], errors: [mockError] }
157+
{ devices: [], errors: [mockError] },
155158
);
156159
const output = await androidEmulatorServices.getEmulatorImages();
157160
assert.deepStrictEqual(output.devices, []);
@@ -192,47 +195,42 @@ describe("androidEmulatorService", () => {
192195

193196
it("should return null when no emulators are available", async () => {
194197
mockGetRunningEmulatorName({});
195-
const emulatorName = await androidEmulatorServices.getRunningEmulatorName(
196-
""
197-
);
198+
const emulatorName =
199+
await androidEmulatorServices.getRunningEmulatorName("");
198200
assert.deepStrictEqual(emulatorName, undefined);
199201
});
200202
it("should return null when there are available emulators but the provided emulatorId is not found", async () => {
201203
mockGetRunningEmulatorName({});
202-
const emulatorName = await androidEmulatorServices.getRunningEmulatorName(
203-
"my emulator Id"
204-
);
204+
const emulatorName =
205+
await androidEmulatorServices.getRunningEmulatorName("my emulator Id");
205206
assert.deepStrictEqual(emulatorName, undefined);
206207
});
207208
it("should return avd emulator when the provided emulatorId is found", async () => {
208209
mockGetRunningEmulatorName({ avd: avdEmulatorName });
209-
const emulatorName = await androidEmulatorServices.getRunningEmulatorName(
210-
avdEmulatorName
211-
);
210+
const emulatorName =
211+
await androidEmulatorServices.getRunningEmulatorName(avdEmulatorName);
212212
assert.deepStrictEqual(emulatorName, avdEmulatorName);
213213
});
214214
it("should return geny emulator when the provided emulatorId is found", async () => {
215215
mockGetRunningEmulatorName({ geny: genyEmulatorName });
216-
const emulatorName = await androidEmulatorServices.getRunningEmulatorName(
217-
genyEmulatorName
218-
);
216+
const emulatorName =
217+
await androidEmulatorServices.getRunningEmulatorName(genyEmulatorName);
219218
assert.deepStrictEqual(emulatorName, genyEmulatorName);
220219
});
221220
it("should return avd emulator when there are avd and geny emulators", async () => {
222221
mockGetRunningEmulatorName({
223222
avd: avdEmulatorName,
224223
geny: genyEmulatorName,
225224
});
226-
const emulatorName = await androidEmulatorServices.getRunningEmulatorName(
227-
avdEmulatorName
228-
);
225+
const emulatorName =
226+
await androidEmulatorServices.getRunningEmulatorName(avdEmulatorName);
229227
assert.deepStrictEqual(emulatorName, avdEmulatorName);
230228
});
231229
});
232230

233231
describe("startEmulator", () => {
234232
function mockStartEmulator(
235-
deviceInfo: Mobile.IDeviceInfo
233+
deviceInfo: Mobile.IDeviceInfo,
236234
): Mobile.IDeviceInfo {
237235
if (deviceInfo.vendor === "Avd") {
238236
androidVirtualDeviceService.startEmulatorArgs = () => [];
@@ -249,7 +247,7 @@ describe("androidEmulatorService", () => {
249247
mockGetRunningEmulatorIds([], []);
250248
mockGetEmulatorImages(
251249
{ devices: [avdEmulator], errors: [] },
252-
{ devices: [], errors: [] }
250+
{ devices: [], errors: [] },
253251
);
254252
const deviceInfo = mockStartEmulator(avdEmulator);
255253
await androidEmulatorServices.startEmulator(avdEmulator);
@@ -259,7 +257,7 @@ describe("androidEmulatorService", () => {
259257
mockGetRunningEmulatorIds([], []);
260258
mockGetEmulatorImages(
261259
{ devices: [], errors: [] },
262-
{ devices: [genyEmulator], errors: [] }
260+
{ devices: [genyEmulator], errors: [] },
263261
);
264262
const deviceInfo = mockStartEmulator(genyEmulator);
265263
assert.deepStrictEqual(deviceInfo, genyEmulator);

0 commit comments

Comments
 (0)