-
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.
feat(colorPicker): add new component colorPicker
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 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,9 @@ | ||
import Char from "./Char"; | ||
|
||
class ColorPicker extends Char { | ||
get showText(): boolean { | ||
return this.parsedWidgetProps.show_text ?? true; | ||
} | ||
} | ||
|
||
export default ColorPicker; |
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,64 @@ | ||
// src/spec/ColorPicker.spec.ts | ||
import WidgetFactory from "../WidgetFactory"; | ||
import ColorPicker from "../ColorPicker"; | ||
import { it, expect, describe } from "vitest"; | ||
|
||
describe("A ColorPicker", () => { | ||
it("should have an id corresponding to field name", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "colorPicker", | ||
}; | ||
|
||
const widget = widgetFactory.createWidget("colorPicker", props); | ||
expect(widget).toBeInstanceOf(ColorPicker); | ||
}); | ||
|
||
it("should properly set label", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "colorPicker", | ||
string: "colorPicker caption", | ||
}; | ||
const widget = widgetFactory.createWidget("colorPicker", props); | ||
|
||
expect(widget.label).toBe("colorPicker caption"); | ||
}); | ||
|
||
describe("showText property", () => { | ||
it("should show text by default", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "colorPicker", | ||
}; | ||
const widget = widgetFactory.createWidget("colorPicker", props); | ||
|
||
expect(widget.showText).toBe(true); | ||
}); | ||
it("should show text when widget_props.showText is true", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "colorPicker", | ||
widget_props: { | ||
show_text: true, | ||
}, | ||
}; | ||
const widget = widgetFactory.createWidget("colorPicker", props); | ||
|
||
expect(widget.showText).toBe(true); | ||
}); | ||
|
||
it("should not show text when widget_props.showText is false", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "colorPicker", | ||
widget_props: { | ||
show_text: false, | ||
}, | ||
}; | ||
const widget = widgetFactory.createWidget("colorPicker", props); | ||
|
||
expect(widget.showText).toBe(false); | ||
}); | ||
}); | ||
}); |