material-web/field/harness.ts
Elizabeth Mitchell c1e7759233 chore(field): remove md3-field class prefix
PiperOrigin-RevId: 509885860
2023-02-15 11:18:08 -08:00

36 lines
851 B
TypeScript

/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {Harness} from '../testing/harness.js';
import {Field} from './lib/field.js';
/**
* Test harness for field elements.
*/
export class FieldHarness extends Harness<Field> {
override async focusWithKeyboard(init: KeyboardEventInit = {}) {
this.element.focused = true;
await super.focusWithKeyboard(init);
}
override async focusWithPointer() {
this.element.focused = true;
await super.focusWithPointer();
}
override async blur() {
this.element.focused = false;
await super.blur();
}
protected override async getInteractiveElement() {
await this.element.updateComplete;
return (this.element.querySelector(':not([slot])') ||
this.element.renderRoot.querySelector('.field')) as HTMLElement;
}
}