Files
PriceUpdaterAppv2/tests/tui/components/common/LoadingIndicator.test.js

98 lines
2.5 KiB
JavaScript

const React = require("react");
const {
LoadingIndicator,
LoadingOverlay,
} = require("../../../../src/tui/components/common/LoadingIndicator.jsx");
describe("LoadingIndicator Component", () => {
it("should create LoadingIndicator component with default props", () => {
const component = React.createElement(LoadingIndicator);
expect(component).toBeDefined();
expect(component.type).toBe(LoadingIndicator);
});
it("should accept custom loading text", () => {
const component = React.createElement(LoadingIndicator, {
text: "Custom loading message",
});
expect(component.props.text).toBe("Custom loading message");
});
it("should accept showSpinner prop", () => {
const component = React.createElement(LoadingIndicator, {
showSpinner: false,
});
expect(component.props.showSpinner).toBe(false);
});
it("should accept progress props", () => {
const component = React.createElement(LoadingIndicator, {
showProgress: true,
progress: 50,
progressMax: 100,
});
expect(component.props.showProgress).toBe(true);
expect(component.props.progress).toBe(50);
expect(component.props.progressMax).toBe(100);
});
it("should accept compact mode prop", () => {
const component = React.createElement(LoadingIndicator, {
compact: true,
});
expect(component.props.compact).toBe(true);
});
it("should accept centered prop", () => {
const component = React.createElement(LoadingIndicator, {
centered: true,
});
expect(component.props.centered).toBe(true);
});
it("should accept color and type props", () => {
const component = React.createElement(LoadingIndicator, {
color: "green",
type: "dots2",
});
expect(component.props.color).toBe("green");
expect(component.props.type).toBe("dots2");
});
});
describe("LoadingOverlay Component", () => {
it("should create LoadingOverlay component", () => {
const component = React.createElement(LoadingOverlay);
expect(component).toBeDefined();
expect(component.type).toBe(LoadingOverlay);
});
it("should accept custom text prop", () => {
const component = React.createElement(LoadingOverlay, {
text: "Processing data...",
});
expect(component.props.text).toBe("Processing data...");
});
it("should accept progress props", () => {
const component = React.createElement(LoadingOverlay, {
showProgress: true,
progress: 75,
progressMax: 100,
});
expect(component.props.showProgress).toBe(true);
expect(component.props.progress).toBe(75);
expect(component.props.progressMax).toBe(100);
});
});