-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/add-multi-email' into alpha
- Loading branch information
Showing
6 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Field from "./Field"; | ||
|
||
class Email extends Field { | ||
_multi: boolean = false; | ||
get multi(): boolean { | ||
return this._multi; | ||
} | ||
|
||
set multi(value: boolean) { | ||
this._multi = value; | ||
} | ||
|
||
_size: number | undefined; | ||
get size(): number | undefined { | ||
return this._size; | ||
} | ||
|
||
set size(value: number | undefined) { | ||
this._size = value; | ||
} | ||
|
||
constructor(props: any) { | ||
super(props); | ||
if (props) { | ||
if (props.size) { | ||
this.size = props.size; | ||
} | ||
} | ||
if (this.parsedWidgetProps.multi) { | ||
this.multi = this.parsedWidgetProps.multi; | ||
} | ||
} | ||
} | ||
|
||
export default Email; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import Email from "../Email"; | ||
|
||
describe("Email", () => { | ||
it("should initialize with default values", () => { | ||
const email = new Email({}); | ||
expect(email.multi).toBe(false); | ||
expect(email.size).toBeUndefined(); | ||
}); | ||
|
||
it("should set multi property correctly from widget_props", () => { | ||
const email = new Email({ widget_props: { multi: true } }); | ||
expect(email.multi).toBe(true); | ||
}); | ||
|
||
it("should set size property correctly", () => { | ||
const email = new Email({ size: 10 }); | ||
expect(email.size).toBe(10); | ||
}); | ||
|
||
it("should update multi property", () => { | ||
const email = new Email({}); | ||
email.multi = true; | ||
expect(email.multi).toBe(true); | ||
}); | ||
|
||
it("should update size property", () => { | ||
const email = new Email({}); | ||
email.size = 20; | ||
expect(email.size).toBe(20); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters