2022-01-18 07:52:24 +00:00
|
|
|
import { defaultValueValidation, PhoneInputWidgetProps } from "./index";
|
|
|
|
|
import _ from "lodash";
|
|
|
|
|
|
|
|
|
|
describe("defaultValueValidation", () => {
|
|
|
|
|
let result: any;
|
|
|
|
|
|
|
|
|
|
it("should validate defaulttext", () => {
|
|
|
|
|
result = defaultValueValidation(
|
|
|
|
|
"0000000000",
|
|
|
|
|
{} as PhoneInputWidgetProps,
|
|
|
|
|
_,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual({
|
|
|
|
|
isValid: true,
|
|
|
|
|
parsed: "0000000000",
|
2023-02-18 12:55:46 +00:00
|
|
|
messages: [{ name: "", message: "" }],
|
2022-01-18 07:52:24 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should validate defaulttext with object value", () => {
|
|
|
|
|
const value = {};
|
|
|
|
|
result = defaultValueValidation(value, {} as PhoneInputWidgetProps, _);
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual({
|
|
|
|
|
isValid: false,
|
|
|
|
|
parsed: JSON.stringify(value, null, 2),
|
2023-02-18 12:55:46 +00:00
|
|
|
messages: [
|
|
|
|
|
{
|
|
|
|
|
name: "TypeError",
|
|
|
|
|
message: "This value must be string",
|
|
|
|
|
},
|
|
|
|
|
],
|
2022-01-18 07:52:24 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|