dynamic-forms-ionic / Class

IonicFormTestUtils

Utility class for testing Ionic dynamic forms

Static Methods

static

assertFormValue()

Asserts that the form has a specific value

Presentation
static assertFormValue(component: DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>, expectedValue: Record<string, unknown>): void;
Parameters
NameTypeDescription
component
DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>
expectedValue
Record<string, unknown>
Returns
void
static

assertIonicFieldError()

Asserts that an Ionic field shows an error message

Presentation
static assertIonicFieldError(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, fieldSelector: string, expectedError?: string | undefined): void;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
fieldSelector
string
expectedError
string | undefined
Returns
void
static

assertIonicFieldValue()

Asserts that an Ionic field has a specific value

Presentation
static assertIonicFieldValue(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, fieldSelector: string, expectedValue: string): void;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
fieldSelector
string
expectedValue
string
Returns
void
static

builder()

Creates a new Ionic form config builder

Presentation
static builder(): IonicFormConfigBuilder;
Returns
static async

createTest()

Creates an Ionic dynamic form test setup with proper providers

Presentation
async static createTest(testConfig: IonicFormTestConfig): Promise<IonicFormTestResult>;
Parameters
NameTypeDescription
testConfig
IonicFormTestConfig
Returns
static

getFormErrors()

Gets validation errors from the component

Presentation
static getFormErrors(component: DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>): any[];
Parameters
NameTypeDescription
component
DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>
Returns
any[]
static

getFormValue()

Gets the current form value from the component

Presentation
static getFormValue(component: DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>): Record<string, unknown>;
Parameters
NameTypeDescription
component
DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>
Returns
Record<string, unknown>
static

getIonicFieldElements()

Gets all Ionic field elements from the fixture

Presentation
static getIonicFieldElements(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, fieldType: string): NodeListOf<Element>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
fieldType
string
Returns
NodeListOf<Element>
static

isFormValid()

Checks if the form is valid

Presentation
static isFormValid(component: DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>): boolean;
Parameters
NameTypeDescription
component
DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>
Returns
boolean
static async

simulateIonicButtonClick()

Simulates Ionic button click Works by finding the button (either in shadow DOM or directly) and clicking it

Presentation
async static simulateIonicButtonClick(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, selector: string): Promise<void>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
selector
string
Returns
Promise<void>
static async

simulateIonicCheckbox()

Simulates Ionic checkbox toggle Works by finding the checkbox through shadow DOM and toggling it

Presentation
async static simulateIonicCheckbox(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, selector: string, checked: boolean): Promise<void>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
selector
string
checked
boolean
Returns
Promise<void>
static async

simulateIonicInput()

Simulates user input on an Ionic input field Works by finding the ion-input component and using its public API

Presentation
async static simulateIonicInput(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, selector: string, value: string): Promise<void>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
selector
string
value
string
Returns
Promise<void>
static async

simulateIonicSelect()

Simulates user selection on an Ionic select

Presentation
async static simulateIonicSelect(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, selectSelector: string, value: string): Promise<void>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
selectSelector
string
value
string
Returns
Promise<void>
static async

simulateIonicToggle()

Simulates Ionic toggle switch Works by finding the toggle through shadow DOM and toggling it

Presentation
async static simulateIonicToggle(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>, selector: string, checked: boolean): Promise<void>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
selector
string
checked
boolean
Returns
Promise<void>
static async

waitForInit()

Waits for the Ionic dynamic form to initialize

Presentation
async static waitForInit(fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>): Promise<void>;
Parameters
NameTypeDescription
fixture
ComponentFixture<DynamicForm<RegisteredFieldTypes[], { [x: string]: Record<string, unknown>; } & Record<string, unknown>>>
Returns
Promise<void>