{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/legacy-form-field/testing/error-harness.ts","../../../../../../../src/material/legacy-form-field/testing/form-field-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ComponentHarnessConstructor, HarnessPredicate} from '@angular/cdk/testing';\n\nimport {_MatErrorHarnessBase, ErrorHarnessFilters} from '@angular/material/form-field/testing';\n\n/**\n * Harness for interacting with a `mat-error` in tests.\n * @deprecated Use `MatErrorHarness` from `@angular/material/form-field/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.\n * @breaking-change 17.0.0\n */\nexport class MatLegacyErrorHarness extends _MatErrorHarnessBase {\n  static hostSelector = '.mat-error';\n\n  /**\n   * Gets a `HarnessPredicate` that can be used to search for an error with specific\n   * attributes.\n   * @param options Options for filtering which error instances are considered a match.\n   * @return a `HarnessPredicate` configured with the given options.\n   */\n  static with<T extends MatLegacyErrorHarness>(\n    this: ComponentHarnessConstructor<T>,\n    options: ErrorHarnessFilters = {},\n  ): HarnessPredicate<T> {\n    return _MatErrorHarnessBase._getErrorPredicate(this, options);\n  }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {HarnessPredicate, parallel} from '@angular/cdk/testing';\nimport {\n  MatDatepickerInputHarness,\n  MatDateRangeInputHarness,\n} from '@angular/material/datepicker/testing';\nimport {\n  FormFieldHarnessFilters,\n  _MatFormFieldHarnessBase,\n} from '@angular/material/form-field/testing';\nimport {MatLegacyInputHarness} from '@angular/material/legacy-input/testing';\nimport {MatLegacySelectHarness} from '@angular/material/legacy-select/testing';\nimport {MatLegacyErrorHarness} from './error-harness';\n\n// TODO(devversion): support support chip list harness\n/**\n * Possible harnesses of controls which can be bound to a form-field.\n * @deprecated Use `FormFieldControlHarness` from `@angular/material/form-field/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.\n * @breaking-change 17.0.0\n */\nexport type LegacyFormFieldControlHarness =\n  | MatLegacyInputHarness\n  | MatLegacySelectHarness\n  | MatDatepickerInputHarness\n  | MatDateRangeInputHarness;\n\n/**\n * Harness for interacting with a standard Material form-field's in tests.\n * @deprecated Use `MatFormFieldHarness` from `@angular/material/form-field/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.\n * @breaking-change 17.0.0\n */\nexport class MatLegacyFormFieldHarness extends _MatFormFieldHarnessBase<\n  LegacyFormFieldControlHarness,\n  typeof MatLegacyErrorHarness\n> {\n  static hostSelector = '.mat-form-field';\n\n  /**\n   * Gets a `HarnessPredicate` that can be used to search for a `MatFormFieldHarness` that meets\n   * certain criteria.\n   * @param options Options for filtering which form field instances are considered a match.\n   * @return a `HarnessPredicate` configured with the given options.\n   */\n  static with(options: FormFieldHarnessFilters = {}): HarnessPredicate<MatLegacyFormFieldHarness> {\n    return new HarnessPredicate(MatLegacyFormFieldHarness, options)\n      .addOption('floatingLabelText', options.floatingLabelText, async (harness, text) =>\n        HarnessPredicate.stringMatches(await harness.getLabel(), text),\n      )\n      .addOption(\n        'hasErrors',\n        options.hasErrors,\n        async (harness, hasErrors) => (await harness.hasErrors()) === hasErrors,\n      )\n      .addOption(\n        'isValid',\n        options.isValid,\n        async (harness, isValid) => (await harness.isControlValid()) === isValid,\n      );\n  }\n\n  protected _prefixContainer = this.locatorForOptional('.mat-form-field-prefix');\n  protected _suffixContainer = this.locatorForOptional('.mat-form-field-suffix');\n  protected _label = this.locatorForOptional('.mat-form-field-label');\n  protected _errors = this.locatorForAll('.mat-error');\n  protected _hints = this.locatorForAll('mat-hint, .mat-hint');\n  protected _inputControl = this.locatorForOptional(MatLegacyInputHarness);\n  protected _selectControl = this.locatorForOptional(MatLegacySelectHarness);\n  protected _datepickerInputControl = this.locatorForOptional(MatDatepickerInputHarness);\n  protected _dateRangeInputControl = this.locatorForOptional(MatDateRangeInputHarness);\n  protected _errorHarness = MatLegacyErrorHarness;\n\n  /** Gets the appearance of the form-field. */\n  async getAppearance(): Promise<'legacy' | 'standard' | 'fill' | 'outline'> {\n    const hostClasses = await (await this.host()).getAttribute('class');\n    if (hostClasses !== null) {\n      const appearanceMatch = hostClasses.match(\n        /mat-form-field-appearance-(legacy|standard|fill|outline)(?:$| )/,\n      );\n      if (appearanceMatch) {\n        return appearanceMatch[1] as 'legacy' | 'standard' | 'fill' | 'outline';\n      }\n    }\n    throw Error('Could not determine appearance of form-field.');\n  }\n\n  /** Whether the form-field has a label. */\n  async hasLabel(): Promise<boolean> {\n    return (await this.host()).hasClass('mat-form-field-has-label');\n  }\n\n  /** Whether the label is currently floating. */\n  async isLabelFloating(): Promise<boolean> {\n    const host = await this.host();\n    const [hasLabel, shouldFloat] = await parallel(() => [\n      this.hasLabel(),\n      host.hasClass('mat-form-field-should-float'),\n    ]);\n    // If there is no label, the label conceptually can never float. The `should-float` class\n    // is just always set regardless of whether the label is displayed or not.\n    return hasLabel && shouldFloat;\n  }\n}\n"],"names":[],"mappings":";;;;;;;AAYA;;;;AAIG;AACG,MAAO,qBAAsB,SAAQ,oBAAoB,CAAA;aACtD,IAAY,CAAA,YAAA,GAAG,YAAY,CAAC,EAAA;AAEnC;;;;;AAKG;AACH,IAAA,OAAO,IAAI,CAET,OAAA,GAA+B,EAAE,EAAA;QAEjC,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC/D;;;ACEH;;;;AAIG;AACG,MAAO,yBAA0B,SAAQ,wBAG9C,CAAA;AAHD,IAAA,WAAA,GAAA;;AA6BY,QAAA,IAAA,CAAA,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;AACrE,QAAA,IAAA,CAAA,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;AACrE,QAAA,IAAA,CAAA,MAAM,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