diff --git a/src/Image.ts b/src/Image.ts index 4479a1f..9da21a4 100644 --- a/src/Image.ts +++ b/src/Image.ts @@ -3,6 +3,10 @@ import Field from "./Field"; /** * Image base64 field */ -class Image extends Field {} +class Image extends Field { + get showControls(): boolean { + return this.parsedWidgetProps?.showControls ?? true; + } +} export default Image; diff --git a/src/spec/Image.spec.ts b/src/spec/Image.spec.ts new file mode 100644 index 0000000..d800228 --- /dev/null +++ b/src/spec/Image.spec.ts @@ -0,0 +1,19 @@ +import { describe, it, expect } from "vitest"; +import Image from "../Image"; + +describe("Image", () => { + it("should have showControls property to true as default", () => { + const props = {}; + const image = new Image(props); + expect(image.showControls).toBe(true); + }); + it("should have showControls property to false", () => { + const props = { + widget_props: { + showControls: false, + }, + }; + const image = new Image(props); + expect(image.showControls).toBe(false); + }); +});