import { ElementProfile, O3rElement, O3rElementConstructor } from './element'; import { GroupProfile, O3rGroupConstructor } from './group'; /** * Interface to describe the Component fixture that is used as an abstraction layer to access the DOM of a component. * It comes with two implementations that are chosen a build time whether you will use it in a karma or protractor * runtime. This way the same fixture is usable for both component and e2e tests. */ export interface ComponentFixtureProfile { /** * Return the root element of the component fixture. */ getElement(): V | undefined; /** * Queries an element using the CSS selector passed as argument. * If the fixture has a context (was created with a TestBed or Protractor element) the query will be applied * to this element's tree only. * @param selector CSS selector for the desired element * @param returnType Constructor of the element expected */ query(selector: string, returnType?: undefined): Promise; query(selector: string, returnType: O3rElementConstructor): Promise; query(selector: string, returnType: O3rElementConstructor | undefined): Promise; /** * Queries the nth element of a list using the CSS selector passed as argument. * If the fixture has a context (was created with a TestBed or Protractor element) the query will be applied * to this element's tree only. * @param selector CSS selector for the desired element * @param index Index of the element to retrieve * @param returnType Constructor of the element expected */ queryNth(selector: string, index: number, returnType?: undefined): Promise; queryNth(selector: string, index: number, returnType: O3rElementConstructor): Promise; queryNth(selector: string, index: number, returnType: O3rElementConstructor | undefined): Promise; /** * Queries a list of elements using the CSS selector passed as argument. * If the fixture has a context (was created with a TestBed or Protractor element) the query will be applied * to this element's tree only. * @param selector CSS selector for the desired elements * @param returnType Constructor of the element expected * @param groupType * @param timeout */ queryAll(selector: string, returnType?: undefined, groupType?: undefined, timeout?: number): Promise; queryAll(selector: string, returnType: O3rElementConstructor, groupType?: undefined, timeout?: number): Promise; queryAll>(selector: string, returnType: O3rElementConstructor, groupType: O3rGroupConstructor, timeout?: number): Promise; queryAll>(selector: string, returnType: O3rElementConstructor | undefined, groupType: O3rGroupConstructor | undefined, timeout?: number): Promise<(T | O3rElement)[] | K>; /** * Returns the component fixtures corresponding to the sub-components. */ getSubComponents(): Promise<{ [componentName: string]: ComponentFixtureProfile[]; }>; /** * Returns true if the provided selector has no match in the document. * A custom timeout value can be passed for asynchronous implementations that support it. * @param selector * @param timeout */ queryNotPresent(selector: string, timeout?: number): Promise; } /** * Interface to tell typescript that the element which implements * it can be used as a prototype */ export type Constructable = new (elem?: ElementProfile, customFixtures?: U) => T; /** * This is the type that has to be extended by each component fixture context * It contains the custom fixture type for a component presenter and its subcomponents fixtures contexts * key: presenter name * fixture: custom presenter type * customSubFixtures: custom fixtures for the presenter subcomponents */ export interface FixtureWithCustom { [fixtureKey: string]: { fixture?: Constructable; customSubFixtures?: FixtureWithCustom; } | undefined; } /** * Mock for Component fixture class. * This class is used for fixture compilation purpose. */ export declare class O3rComponentFixture implements ComponentFixtureProfile { constructor(_element?: V); /** * Throws an exception if the element is undefined. * Otherwise returns the element. * @param _element ElementProfile to test * @param _timeout specific timeout that will throw when reach */ protected throwOnUndefinedElement(_element: T | undefined, _timeout?: number): Promise; /** * Throws an exception if the element is undefined. * Otherwise returns the element. * @param _element ElementProfile to test * @param _timeout specific timeout that will throw when reach */ protected throwOnUndefined(_element: Promise, _timeout?: number): Promise; /** * Get the element associated to the selector if present * @param selector Selector to access the element * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement * @param options Options supported * @param options.index index Select the element associated to the index * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present * @param options.timeout Duration to wait for the element to be present before it throws */ protected queryWithOptions(_selector: string, _elementConstructor: undefined, _options: { index?: number; shouldThrowIfNotPresent?: boolean; timeout?: number; }): Promise; protected queryWithOptions(_selector: string, _elementConstructor: O3rElementConstructor, _options: { index?: number; shouldThrowIfNotPresent?: boolean; timeout?: number; }): Promise; /** * Get text from the element associated to the given selector, or undefined if the element is not found or not visible * @param _selector Selector to access the element * @param _options Options supported * @param _options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement * @param _options.index index Select the element associated to the index * @param _options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present * @param _options.timeout Duration to wait for the element to be present before it throws */ protected getText(_selector: string, _options?: { elementConstructor?: O3rElementConstructor | undefined; index?: number; shouldThrowIfNotPresent?: boolean; timeout?: number; }): Promise; /** * Check if the element associated to the given selector is visible * @param _selector Selector to access the element * @param _options Options supported * @param _options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement * @param _options.index index Select the element associated to the index * @param _options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present * @param _options.timeout Duration to wait for the element to be present before it throws */ protected isVisible(_selector: string, _options?: { elementConstructor?: O3rElementConstructor | undefined; index?: number; shouldThrowIfNotPresent?: boolean; timeout?: number; }): Promise; /** * Click on the element associated to the given selector if it exists and is visible * @param _selector Selector to access the element * @param _options Options supported * @param _options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement * @param _options.index index Select the element associated to the index * @param _options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present * @param _options.timeout Duration to wait for the element to be present before it throws */ protected click(_selector: string, _options?: { elementConstructor?: O3rElementConstructor | undefined; index?: number; shouldThrowIfNotPresent?: boolean; timeout?: number; }): Promise; /** @inheritdoc */ query(_selector: string, _returnType?: undefined, timeout?: number): Promise; /** @inheritdoc */ query(_selector: string, _returnType: O3rElementConstructor, timeout?: number): Promise; /** @inheritdoc */ queryAll(_selector: string, _returnType?: undefined, _groupType?: undefined, timeout?: number): Promise; /** @inheritdoc */ queryAll(_selector: string, _returnType: O3rElementConstructor, _groupType?: undefined, timeout?: number): Promise; /** @inheritdoc */ queryAll>(_selector: string, _returnType: O3rElementConstructor, _groupType: O3rGroupConstructor, timeout?: number): Promise; /** @inheritdoc */ getElement(): V | undefined; /** @inheritdoc */ getSubComponents(): Promise<{ [componentName: string]: ComponentFixtureProfile[]; }>; /** @inheritDoc */ queryNotPresent(_selector: string, _timeout?: number): Promise; /** * @inheritDoc */ queryNth(_selector: string, _index: number, _returnType?: undefined): Promise; queryNth(_selector: string, _index: number, _returnType: O3rElementConstructor): Promise; } //# sourceMappingURL=component-fixture.d.ts.map