{"version":3,"file":"icon-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/icon/testing/icon-harness-filters.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/icon/testing/icon-harness.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/icon/testing/fake-icon-registry.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.dev/license\n */\n\nimport {BaseHarnessFilters} from '@angular/cdk/testing';\n\n/** Possible types of icons. */\nexport enum IconType {\n  SVG,\n  FONT,\n}\n\n/** A set of criteria that can be used to filter a list of `MatIconHarness` instances. */\nexport interface IconHarnessFilters extends BaseHarnessFilters {\n  /** Filters based on the typef of the icon. */\n  type?: IconType;\n  /** Filters based on the name of the icon. */\n  name?: string | RegExp;\n  /** Filters based on the namespace of the icon. */\n  namespace?: string | null | RegExp;\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.dev/license\n */\n\nimport {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {IconHarnessFilters, IconType} from './icon-harness-filters';\n\n/** Harness for interacting with a standard mat-icon in tests. */\nexport class MatIconHarness extends ComponentHarness {\n  /** The selector for the host element of a `MatIcon` instance. */\n  static hostSelector = '.mat-icon';\n\n  /**\n   * Gets a `HarnessPredicate` that can be used to search for a `MatIconHarness` that meets\n   * certain criteria.\n   * @param options Options for filtering which icon instances are considered a match.\n   * @return a `HarnessPredicate` configured with the given options.\n   */\n  static with(options: IconHarnessFilters = {}): HarnessPredicate<MatIconHarness> {\n    return new HarnessPredicate(MatIconHarness, options)\n      .addOption('type', options.type, async (harness, type) => (await harness.getType()) === type)\n      .addOption('name', options.name, (harness, text) =>\n        HarnessPredicate.stringMatches(harness.getName(), text),\n      )\n      .addOption('namespace', options.namespace, (harness, text) =>\n        HarnessPredicate.stringMatches(harness.getNamespace(), text),\n      );\n  }\n\n  /** Gets the type of the icon. */\n  async getType(): Promise<IconType> {\n    const type = await (await this.host()).getAttribute('data-mat-icon-type');\n    return type === 'svg' ? IconType.SVG : IconType.FONT;\n  }\n\n  /** Gets the name of the icon. */\n  async getName(): Promise<string | null> {\n    const host = await this.host();\n    const nameFromDom = await host.getAttribute('data-mat-icon-name');\n\n    // If we managed to figure out the name from the attribute, use it.\n    if (nameFromDom) {\n      return nameFromDom;\n    }\n\n    // Some icons support defining the icon as a ligature.\n    // As a fallback, try to extract it from the DOM text.\n    if ((await this.getType()) === IconType.FONT) {\n      // Other directives may add content to the icon (e.g. `MatBadge`), however only the direct\n      // text nodes affect the name of the icon. Exclude all element descendants from the result.\n      const text = await host.text({exclude: '*'});\n\n      // There are some internal cases where the icon name is wrapped in another node.\n      // Fall back to extracting the entire text if we ended up excluding everything above.\n      return text.length > 0 ? text : host.text();\n    }\n\n    return null;\n  }\n\n  /** Gets the namespace of the icon. */\n  async getNamespace(): Promise<string | null> {\n    return (await this.host()).getAttribute('data-mat-icon-namespace');\n  }\n\n  /** Gets whether the icon is inline. */\n  async isInline(): Promise<boolean> {\n    return (await this.host()).hasClass('mat-icon-inline');\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.dev/license\n */\n\nimport {Injectable, NgModule, OnDestroy} from '@angular/core';\nimport {MatIconRegistry} from '../../icon';\nimport {Observable, of as observableOf} from 'rxjs';\n\ntype PublicApi<T> = {\n  [K in keyof T]: T[K] extends (...x: any[]) => T ? (...x: any[]) => PublicApi<T> : T[K];\n};\n\n/**\n * A null icon registry that must be imported to allow disabling of custom\n * icons.\n */\n@Injectable()\nexport class FakeMatIconRegistry implements PublicApi<MatIconRegistry>, OnDestroy {\n  addSvgIcon(): this {\n    return this;\n  }\n\n  addSvgIconLiteral(): this {\n    return this;\n  }\n\n  addSvgIconInNamespace(): this {\n    return this;\n  }\n\n  addSvgIconLiteralInNamespace(): this {\n    return this;\n  }\n\n  addSvgIconSet(): this {\n    return this;\n  }\n\n  addSvgIconSetLiteral(): this {\n    return this;\n  }\n\n  addSvgIconSetInNamespace(): this {\n    return this;\n  }\n\n  addSvgIconSetLiteralInNamespace(): this {\n    return this;\n  }\n\n  registerFontClassAlias(): this {\n    return this;\n  }\n\n  classNameForFontAlias(alias: string): string {\n    return alias;\n  }\n\n  getDefaultFontSetClass() {\n    return ['material-icons'];\n  }\n\n  getSvgIconFromUrl(): Observable<SVGElement> {\n    return observableOf(this._generateEmptySvg());\n  }\n\n  getNamedSvgIcon(): Observable<SVGElement> {\n    return observableOf(this._generateEmptySvg());\n  }\n\n  setDefaultFontSetClass(): this {\n    return this;\n  }\n\n  addSvgIconResolver(): this {\n    return this;\n  }\n\n  ngOnDestroy() {}\n\n  private _generateEmptySvg(): SVGElement {\n    const emptySvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n    emptySvg.classList.add('fake-testing-svg');\n    // Emulate real icon characteristics from `MatIconRegistry` so size remains consistent in tests.\n    emptySvg.setAttribute('fit', '');\n    emptySvg.setAttribute('height', '100%');\n    emptySvg.setAttribute('width', '100%');\n    emptySvg.setAttribute('preserveAspectRatio', 'xMidYMid meet');\n    emptySvg.setAttribute('focusable', 'false');\n    return emptySvg;\n  }\n}\n\n/** Import this module in tests to install the null icon registry. */\n@NgModule({\n  providers: [{provide: MatIconRegistry, useClass: FakeMatIconRegistry}],\n})\nexport class MatIconTestingModule {}\n"],"names":["IconType","MatIconHarness","ComponentHarness","hostSelector","with","options","HarnessPredicate","addOption","type","harness","getType","name","text","stringMatches","getName","namespace","getNamespace","host","getAttribute","SVG","FONT","nameFromDom","exclude","length","isInline","hasClass","FakeMatIconRegistry","addSvgIcon","addSvgIconLiteral","addSvgIconInNamespace","addSvgIconLiteralInNamespace","addSvgIconSet","addSvgIconSetLiteral","addSvgIconSetInNamespace","addSvgIconSetLiteralInNamespace","registerFontClassAlias","classNameForFontAlias","alias","getDefaultFontSetClass","getSvgIconFromUrl","observableOf","_generateEmptySvg","getNamedSvgIcon","setDefaultFontSetClass","addSvgIconResolver","ngOnDestroy","emptySvg","document","createElementNS","classList","add","setAttribute","deps","target","i0","ɵɵFactoryTarget","Injectable","decorators","MatIconTestingModule","NgModule","providers","provide","MatIconRegistry","useClass","args"],"mappings":";;;;;;;;;;IAWYA;AAAZ,CAAA,UAAYA,QAAQ,EAAA;EAClBA,QAAA,CAAAA,QAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA,KAAG;EACHA,QAAA,CAAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI;AACN,CAAC,EAHWA,QAAQ,KAARA,QAAQ,GAGnB,EAAA,CAAA,CAAA;;ACFK,MAAOC,cAAe,SAAQC,gBAAgB,CAAA;EAElD,OAAOC,YAAY,GAAG,WAAW;AAQjC,EAAA,OAAOC,IAAIA,CAACC,OAAA,GAA8B,EAAE,EAAA;AAC1C,IAAA,OAAO,IAAIC,gBAAgB,CAACL,cAAc,EAAEI,OAAO,CAAA,CAChDE,SAAS,CAAC,MAAM,EAAEF,OAAO,CAACG,IAAI,EAAE,OAAOC,OAAO,EAAED,IAAI,KAAK,CAAC,MAAMC,OAAO,CAACC,OAAO,EAAE,MAAMF,IAAI,CAAA,CAC3FD,SAAS,CAAC,MAAM,EAAEF,OAAO,CAACM,IAAI,EAAE,CAACF,OAAO,EAAEG,IAAI,KAC7CN,gBAAgB,CAACO,aAAa,CAACJ,OAAO,CAACK,OAAO,EAAE,EAAEF,IAAI,CAAC,CAAA,CAExDL,SAAS,CAAC,WAAW,EAAEF,OAAO,CAACU,SAAS,EAAE,CAACN,OAAO,EAAEG,IAAI,KACvDN,gBAAgB,CAACO,aAAa,CAACJ,OAAO,CAACO,YAAY,EAAE,EAAEJ,IAAI,CAAC,CAC7D;AACL;EAGA,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