Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@form()
class Test extends CustomElement {
@gear() public readonly formApi!: FormApi;
@gear() public readonly state!: FormState;
@option()
public initialValues: object = {
bar: 2,
foo: 1,
};
@option()
public onSubmit(): void {}
}
const tag = unsafeStatic(defineCE(Test));
await fixture(
html`<${tag} .initialValues="${{
bar: 3,
foo: 3,
}}">`,
);
expect(formSpyObject.initialize).toHaveBeenCalledWith({
bar: 3,
foo: 3,
});
});
@option()
public onSubmit(): void {}
}
@field()
class Field extends CustomElement {
@gear() public readonly formApi!: FormApi;
@gear() public readonly input!: FieldInputProps;
@gear() public readonly meta!: FieldMetaProps;
@option() public readonly name: string = 'test';
}
const formTag = unsafeStatic(defineCE(Form));
const fieldTag = unsafeStatic(defineCE(Field));
const validate = value => (value ? undefined : 'Required');
await fixture(html`
<${formTag}>
<${fieldTag} .validate="${validate}">
`);
expect(scheduler).not.toHaveBeenCalled();
});
@gear() public readonly state!: FormState;
@option()
public onSubmit(): void {}
}
@field()
class Field extends CustomElement {
@gear() public readonly formApi!: FormApi;
@gear() public readonly input!: FieldInputProps;
@gear() public readonly meta!: FieldMetaProps;
@option() public readonly name: string = 'test';
}
const formTag = unsafeStatic(defineCE(Form));
const fieldTag = unsafeStatic(defineCE(Field));
const validate = value => (value ? undefined : 'Required');
await fixture(html`
<${formTag}>
<${fieldTag} .validate="${validate}">
`);
expect(scheduler).not.toHaveBeenCalled();
});