import { expect } from "@open-wc/testing" ; import { isUpdate , Update , WizardActor , WizardInput } from "../../../src/foundation.js" ; import { WizardTextField } from "../../../src/wizard-textfield.js" ; const noOp = ( ) => { return ; } ; const newWizard = ( done = noOp ) => { const element = document . createElement ( 'mwc-dialog' ) ; element . close = done ; return element ; } ; export async function setWizardTextFieldValue ( field , value ) { if ( field . nullSwitch && ! field . nullSwitch . checked ) { field . nullSwitch ?. click ( ) ; } field . maybeValue = value ; await field . requestUpdate ( ) ; } export function executeWizardUpdateAction ( wizardActor , inputs ) { const updateActions = wizardActor ( inputs , newWizard ( ) ) ; expect ( updateActions . length ) . to . equal ( 1 ) ; expect ( updateActions [ 0 ] ) . to . satisfy ( isUpdate ) ; return < Update > updateActions [ 0 ] ; } export function expectWizardNoUpdateAction ( wizardActor , inputs ) { const updateActions = wizardActor ( inputs , newWizard ( ) ) ; expect ( updateActions ) . to . be . empty ; } export async function fetchDoc ( docName ) { return await fetch ( docName ) . then ( response => response . text ( ) ) . then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ; }