Skip to content

Commit f959353

Browse files
committed
refactor(electron): address lint warnings
- Updated the `createBinaryPathResult` function to utilize a new `BinaryPathResultOptions` interface, enhancing type safety and clarity. - Replaced deprecated `success` pattern with the `ok` pattern and adjusted the handling of binary paths and validation attempts. - Ensured consistent usage of optional chaining and default values for better reliability in path generation and validation.
1 parent 4864ecb commit f959353

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

packages/electron-service/test/testHelpers.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
import type { BinaryPathResult } from '@wdio/native-types';
1+
import type { BinaryPathResult, PathValidationAttempt } from '@wdio/native-types';
22

3-
/**
4-
* Test helper to create properly typed BinaryPathResult mocks
5-
* Uses the new `ok` pattern instead of the deprecated `success` pattern
6-
*/
7-
export function createBinaryPathResult(options: {
3+
interface BinaryPathResultOptions {
84
success: boolean;
95
binaryPath?: string;
106
paths?: string[];
11-
attempts?: Array<{ path: string; valid: boolean; error?: { type: string; message: string; code?: string } }>;
12-
}): BinaryPathResult {
7+
attempts?: PathValidationAttempt[];
8+
}
9+
10+
export function createBinaryPathResult(options: BinaryPathResultOptions): BinaryPathResult {
1311
if (options.success) {
12+
const binaryPath = options.binaryPath ?? '';
1413
return {
1514
ok: true,
1615
value: {
17-
binaryPath: options.binaryPath!,
16+
binaryPath,
1817
pathGeneration: {
1918
ok: true,
2019
value: {
21-
paths: options.paths || [options.binaryPath!],
20+
paths: options.paths || [binaryPath],
2221
},
2322
},
2423
pathValidation: {
2524
ok: true,
2625
value: {
27-
validPath: options.binaryPath!,
28-
attempts: options.attempts || [{ path: options.binaryPath!, valid: true }],
26+
validPath: binaryPath,
27+
attempts: options.attempts || [{ path: binaryPath, valid: true }],
2928
},
3029
},
3130
},
@@ -36,7 +35,7 @@ export function createBinaryPathResult(options: {
3635
ok: false,
3736
error: {
3837
pathGeneration: {
39-
ok: options.paths ? true : false,
38+
ok: !!options.paths,
4039
value: options.paths ? { paths: options.paths } : undefined,
4140
error: !options.paths ? { errors: [{ type: 'CONFIG_INVALID', message: 'No paths generated' }] } : undefined,
4241
} as import('@wdio/native-types').PathGenerationResult,

0 commit comments

Comments
 (0)