-
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 pull request #143 from gisce/feature/spinner-component
Spinner component
- Loading branch information
Showing
4 changed files
with
64 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,23 @@ | ||
import ContainerWidget from "./ContainerWidget"; | ||
|
||
class Spinner extends ContainerWidget { | ||
_loading = false; | ||
get loading(): boolean { | ||
return this._loading; | ||
} | ||
|
||
set loading(value: boolean) { | ||
this._loading = value; | ||
} | ||
|
||
constructor(props?: any) { | ||
super(props); | ||
if (props) { | ||
if (props.loading) { | ||
this._loading = props.loading; | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default Spinner; |
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,35 @@ | ||
import WidgetFactory from "../WidgetFactory"; | ||
import Spinner from "../Spinner"; | ||
import { it, expect, describe } from "vitest"; | ||
|
||
describe("A Spinner", () => { | ||
it("should have an id corresponding to field name", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "spinner", | ||
}; | ||
|
||
const widget = widgetFactory.createWidget("spinner", props); | ||
expect(widget).toBeInstanceOf(Spinner); | ||
}); | ||
|
||
it("should properly set label", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "spinner", | ||
string: "spinner caption", | ||
}; | ||
const widget = widgetFactory.createWidget("spinner", props); | ||
|
||
expect(widget.label).toBe("spinner caption"); | ||
}); | ||
|
||
it("should have loading as false by default", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "spinner", | ||
}; | ||
const widget = widgetFactory.createWidget("spinner", props); | ||
expect(widget.loading).toBe(false); | ||
}); | ||
}); |