Skip to content

Commit 7001d75

Browse files
committed
Do not refactor findOptionByValue
1 parent de9ff21 commit 7001d75

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/test-utils/dom/autosuggest/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import { createWrapper, ElementWrapper, usesDom } from '@cloudscape-design/test-utils-core/dom';
4+
import { escapeSelector } from '@cloudscape-design/test-utils-core/utils';
45
import { act } from '@cloudscape-design/test-utils-core/utils-dom';
56

67
import InputWrapper from '../input';
@@ -32,6 +33,16 @@ export class AutosuggestDropdownWrapper extends BaseDropdownContentWrapper {
3233
);
3334
}
3435

36+
/**
37+
* Returns an option from the autosuggest by its value
38+
*
39+
* @param value The 'value' of the option.
40+
*/
41+
findOptionByValue(value: string): OptionWrapper | null {
42+
const toReplace = escapeSelector(value);
43+
return this.findComponent(`.${OptionWrapper.rootSelector}[data-value="${toReplace}"]`, OptionWrapper);
44+
}
45+
3546
/**
3647
* Returns an option from the dropdown.
3748
*

src/test-utils/dom/internal/dropdown-host.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ export class BaseDropdownContentWrapper extends ComponentWrapper {
184184
return dropdown.findOpenDropdown();
185185
}
186186

187-
/**
188-
* Returns an option from the autosuggest by its value
189-
*
190-
* @param value The 'value' of the option.
191-
*/
192-
findOptionByValue(value: string): OptionWrapper | null {
193-
const toReplace = escapeSelector(value);
194-
return this.findComponent(`.${OptionWrapper.rootSelector}[data-value="${toReplace}"]`, OptionWrapper);
195-
}
196-
197187
/**
198188
* Use this element to scroll through the list of options
199189
*/
@@ -213,6 +203,15 @@ export class DropdownContentWrapper extends BaseDropdownContentWrapper {
213203
OptionWrapper
214204
);
215205
}
206+
/**
207+
* Returns an option from the autosuggest by its value
208+
*
209+
* @param value The 'value' of the option.
210+
*/
211+
findOptionByValue(value: string): OptionWrapper | null {
212+
const toReplace = escapeSelector(value);
213+
return this.findComponent(`.${OptionWrapper.rootSelector}[data-value="${toReplace}"]`, OptionWrapper);
214+
}
216215

217216
/**
218217
* Returns an option from the dropdown.

0 commit comments

Comments
 (0)