Skip to content

Commit

Permalink
Merge pull request #146 from gisce/container-spinner
Browse files Browse the repository at this point in the history
Allow loading in Page and Group components
  • Loading branch information
ecarreras authored Dec 9, 2024
2 parents a6c6a50 + 57c3f16 commit 2e4b523
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ContainerWidget from "./ContainerWidget";
import Spinner from "./Spinner";

class Group extends ContainerWidget {
class Group extends Spinner {
_icon: string | null = null;
get icon(): string | null {
return this._icon;
Expand Down
4 changes: 2 additions & 2 deletions src/Page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ContainerWidget from "./ContainerWidget";
import Spinner from "./Spinner";

class Page extends ContainerWidget {
class Page extends Spinner {
_icon: string | null = null;
get icon(): string | null {
return this._icon;
Expand Down
19 changes: 19 additions & 0 deletions src/spec/Group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,23 @@ describe("A Group", () => {
const widget = widgetFactory.createWidget("group", props);
expect(widget.icon).toEqual("home");
});
describe("working as a spinner", () => {
it("should be loading false as default", () => {
const widgetFactory = new WidgetFactory();
const props = {
string: "A group",
};
const widget = widgetFactory.createWidget("group", props);
expect(widget.loading).toBe(false);
});
it("should be loading true if set", () => {
const widgetFactory = new WidgetFactory();
const props = {
string: "A group",
loading: true,
};
const widget = widgetFactory.createWidget("group", props);
expect(widget.loading).toBe(true);
});
});
});
19 changes: 19 additions & 0 deletions src/spec/Page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,23 @@ describe("A Page", () => {
expect(widget.label).toBe("Page 1");
expect(widget.icon).toBe("home");
});
describe("working as a Spinner", () => {
it("should have loading to be false by default", () => {
const widgetFactory = new WidgetFactory();
const props = {
string: "Page 1",
};
const widget = widgetFactory.createWidget("page", props);
expect(widget.loading).toBe(false);
});
it("should allow setting loading to true", () => {
const widgetFactory = new WidgetFactory();
const props = {
string: "Page 1",
loading: true,
};
const widget = widgetFactory.createWidget("page", props);
expect(widget.loading).toBe(true);
});
});
});

0 comments on commit 2e4b523

Please sign in to comment.