Skip to content

Commit 715e05d

Browse files
michaelwarren1106daKmoR
authored andcommitted
chore(test-runner-commands): fix formatting
1 parent 3dbdbf5 commit 715e05d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

packages/test-runner-commands/src/selectOptionPlugin.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { TestRunnerPlugin } from '@web/test-runner-core';
22
import type { ChromeLauncher } from '@web/test-runner-chrome';
33
import type { PlaywrightLauncher } from '@web/test-runner-playwright';
44

5-
type SelectByValuePayload = { selector: string, value: string };
6-
type SelectByLabelPayload = { selector: string, label: string };
7-
type SelectMultipleValuesPayload = { selector: string, values: string[] };
5+
type SelectByValuePayload = { selector: string; value: string };
6+
type SelectByLabelPayload = { selector: string; label: string };
7+
type SelectMultipleValuesPayload = { selector: string; values: string[] };
88

9-
export type SelectOptionPayload = SelectByLabelPayload | SelectByValuePayload | SelectMultipleValuesPayload;
9+
export type SelectOptionPayload =
10+
| SelectByLabelPayload
11+
| SelectByValuePayload
12+
| SelectMultipleValuesPayload;
1013

1114
function isObject(payload: unknown): payload is Record<string, unknown> {
1215
return payload != null && typeof payload === 'object';
@@ -17,14 +20,16 @@ function isSelectOptionPayload(payload: unknown): boolean {
1720

1821
if (!isObject(payload)) throw new Error('You must provide a `SelectOptionPayload` object');
1922

20-
if(!payload.selector || typeof payload.selector !== 'string') {
23+
if (!payload.selector || typeof payload.selector !== 'string') {
2124
throw new Error(`You must provide a selector representing the select you wish to locate`);
2225
}
2326

2427
const numberOfValidOptions = Object.keys(payload).filter(key =>
2528
validOptions.includes(key),
2629
).length;
27-
const unknownOptions = Object.keys(payload).filter(key => ![...validOptions, 'selector'].includes(key));
30+
const unknownOptions = Object.keys(payload).filter(
31+
key => ![...validOptions, 'selector'].includes(key),
32+
);
2833

2934
if (numberOfValidOptions === 0)
3035
throw new Error(
@@ -43,14 +48,13 @@ function isValuePayload(payload: SelectOptionPayload): payload is SelectByValueP
4348
}
4449

4550
function isLabelPayload(payload: SelectOptionPayload): payload is SelectByLabelPayload {
46-
return 'selector' in payload && 'label' in payload;
51+
return 'selector' in payload && 'label' in payload;
4752
}
4853

4954
function isMultiplePayload(payload: SelectOptionPayload): payload is SelectMultipleValuesPayload {
50-
return 'selector' in payload && 'values' in payload;
55+
return 'selector' in payload && 'values' in payload;
5156
}
5257

53-
5458
export function selectOptionPlugin(): TestRunnerPlugin<SelectOptionPayload> {
5559
return {
5660
name: 'select-option-command',
@@ -72,7 +76,7 @@ export function selectOptionPlugin(): TestRunnerPlugin<SelectOptionPayload> {
7276
return true;
7377
} else if (isMultiplePayload(payload)) {
7478
const { selector, values } = payload;
75-
await page.locator(selector).selectOption([ ...values ]);
79+
await page.locator(selector).selectOption([...values]);
7680
return true;
7781
}
7882
}
@@ -91,13 +95,13 @@ export function selectOptionPlugin(): TestRunnerPlugin<SelectOptionPayload> {
9195
} else {
9296
throw new Error(`Puppeteer only supports selection of an option by its value(s):
9397
https://pptr.dev/next/api/puppeteer.page.select#parameters
94-
`)
98+
`);
9599
}
96100
}
97101

98102
// handle specific behavior for webdriver
99-
if (session.browser.type === 'webdriver') {
100-
throw new Error(`Selecting an option via a browser driver command is not currently implemented in WebDriver yet.
103+
if (session.browser.type === 'webdriver') {
104+
throw new Error(`Selecting an option via a browser driver command is not currently implemented in WebDriver yet.
101105
https://www.selenium.dev/documentation/webdriver/elements/select_lists/
102106
103107
When using WebDriver, the current recommended (September 2022) approach is to:
@@ -109,7 +113,9 @@ export function selectOptionPlugin(): TestRunnerPlugin<SelectOptionPayload> {
109113
}
110114

111115
// you might not be able to support all browser launchers
112-
throw new Error(`Selection of select element options is not supported for browser type ${session.browser.type}.`);
116+
throw new Error(
117+
`Selection of select element options is not supported for browser type ${session.browser.type}.`,
118+
);
113119
}
114120
},
115121
};

0 commit comments

Comments
 (0)