{"version":3,"file":"TestAdapter.cjs","sources":["../../src/UNSAFE_TestAdapter/TestAdapter.ts"],"sourcesContent":["import { TestDriver, TestElement, getTestDriver } from '../UNSAFE_Driver';\nimport { ElementLocator } from '../UNSAFE_Locators';\n\n/**\n * The base class for portable test adapters. Test adapters should extend this\n * class to provide uniform construction.\n */\nexport class TestAdapter {\n  private _elementQuery: () => Promise<TestElement>;\n\n  /**\n   * Create the test adapter from the locator and optional TestDriver or TestElement.\n   * If a driverOrElement is given, the locator will be searched from there.\n   * @param locator The ElementLocator used to search for the component\n   * @param driverOrElement The optional TestDriver or TestElement from which to search. If\n   * TestElement is given, locator will search underneath that element. If TestDriver is given\n   * or the parameter is undefined, the DOM is searched globally.\n   */\n  constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement) {\n    this._elementQuery = () => {\n      if (driverOrElement) {\n        return driverOrElement.waitForElement(locator);\n      } else {\n        return getTestDriver().waitForElement(locator);\n      }\n    };\n  }\n\n  /**\n   * Get the TestElement for the root DOM of this component. This method will query the DOM environment\n   * for the matching element each time it's calld. Do not store the reference to the returned element.\n   * It's recommended that this method be called each time element is needed, to avoid the chance that\n   * the reference may become stale due to a rerender.\n   * @returns Promise resolving to the TestElement for this adapter\n   */\n  protected getElement() {\n    return this._elementQuery();\n  }\n\n  protected getTestDriver() {\n    return getTestDriver();\n  }\n}\n"],"names":["getTestDriver"],"mappings":";;;;;;AAGA;;;AAGG;MACU,WAAW,CAAA;AAGtB;;;;;;;AAOG;IACH,WAAY,CAAA,OAAuB,EAAE,eAA0C,EAAA;AAC7E,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;YACxB,IAAI,eAAe,EAAE;AACnB,gBAAA,OAAO,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;iBAAM;AACL,gBAAA,OAAOA,wBAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;AACH,SAAC,CAAC;KACH;AAED;;;;;;AAMG;IACO,UAAU,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;KAC7B;IAES,aAAa,GAAA;QACrB,OAAOA,wBAAa,EAAE,CAAC;KACxB;AACF;;;;"}