PromucFlow_constructor/app/client/src/widgets/CurrencyInputWidget/widget/derived.test.ts
balajisoundar 02785b90b2
feat: Input, Phone no., Currency input widget (#10259)
* feat: Input, Phone no., Currency Widget

* cypress tests, jest test, QA and CR callouts

* fix tests

* Cypress and jest test fixes
2022-01-18 13:22:24 +05:30

66 lines
1.3 KiB
TypeScript

import derivedProperty from "./derived";
describe("Derived property - ", () => {
describe("isValid property", () => {
it("should test isRequired", () => {
let isValid = derivedProperty.isValid({
text: undefined,
isRequired: false,
});
expect(isValid).toBeTruthy();
isValid = derivedProperty.isValid({
text: undefined,
isRequired: true,
});
expect(isValid).toBeFalsy();
isValid = derivedProperty.isValid({
value: 100,
text: "100",
isRequired: true,
});
expect(isValid).toBeTruthy();
});
it("should test validation", () => {
let isValid = derivedProperty.isValid({
value: 100,
text: "100",
validation: false,
});
expect(isValid).toBeFalsy();
isValid = derivedProperty.isValid({
value: 100,
text: "100",
validation: true,
});
expect(isValid).toBeTruthy();
});
it("should test regex validation", () => {
let isValid = derivedProperty.isValid({
value: 100,
text: "100",
regex: "^100$",
});
expect(isValid).toBeTruthy();
isValid = derivedProperty.isValid({
value: 101,
text: "101",
regex: "^100$",
});
expect(isValid).toBeFalsy();
});
});
});