Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, fireEvent } from "@testing-library/react-native";
import Big from "big.js";
import { ActionValue } from "mendix";
import { BackgroundGradient, props } from "../BackgroundGradient";
import defaultStyle from "../ui/Styles";

describe("Background gradient", () => {
let defaultProps: props;
Expand Down Expand Up @@ -110,4 +111,9 @@ describe("Background gradient", () => {
fireEvent.press(pressable);
expect(actionExecution).toHaveBeenCalled();
});

it("preserves expected style key set", () => {
const keys = Object.keys(defaultStyle).sort();
expect(keys).toEqual(["angle", "colorList", "container", "opacity"]);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { aggregateGridPadding, mapToAxisStyle, mapToGridStyle, mapToBarStyles } from "../StyleUtils";
import { BarChartAxisStyle, BarChartGridStyle, BarChartStyle } from "../../ui/Styles";
import { BarChartAxisStyle, BarChartGridStyle, BarChartStyle, defaultBarChartStyle } from "../../ui/Styles";

describe("StyleMappers", () => {
describe("mapToGridStyle", () => {
Expand Down Expand Up @@ -210,3 +210,10 @@ describe("aggregateGridPadding", () => {
expect(aggregateGridPadding(undefined)).toBeUndefined();
});
});

describe("Style schema guardrail", () => {
it("preserves expected style key set", () => {
const keys = Object.keys(defaultBarChartStyle).sort();
expect(keys).toEqual(["chart", "container", "errorMessage", "grid", "legend", "xAxis"]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { actionValue, EditableValueBuilder } from "@mendix/piw-utils-internal";
import { render } from "@testing-library/react-native";
import { View } from "react-native";
import { BarcodeScanner, Props } from "../BarcodeScanner";
import { defaultBarcodeScannerStyle } from "../ui/styles";

let mockOnCodeScanned: ((codes: Array<{ value: string }>) => void) | undefined;

Expand Down Expand Up @@ -68,4 +69,9 @@ describe("BarcodeScanner", () => {
expect(defaultProps.barcode.setValue).toHaveBeenCalledWith("value1");
expect(onDetectAction.execute).toHaveBeenCalledTimes(2);
});

it("preserves expected style key set", () => {
const keys = Object.keys(defaultBarcodeScannerStyle).sort();
expect(keys).toEqual(["container", "mask"]);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CarouselProps } from "../../typings/CarouselProps";
import { CarouselStyle } from "../ui/styles";
import { CarouselStyle, defaultCarouselStyle } from "../ui/styles";
import { render } from "@testing-library/react-native";
import { Text, View } from "react-native";
import { buildWidgetValue, ListValueBuilder } from "@mendix/piw-utils-internal";
Expand Down Expand Up @@ -47,4 +47,9 @@ describe("Carousel", () => {
// };
// expect(render(<Carousel {...props} />).toJSON()).toMatchSnapshot();
// });

it("preserves expected style key set", () => {
const keys = Object.keys(defaultCarouselStyle).sort();
expect(keys).toEqual(["cardLayout", "container", "fullWidthLayout"]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Slider from "react-native-slider";
import { fireEvent, render, RenderAPI } from "@testing-library/react-native";
import { ReactTestInstance } from "react-test-renderer";
import { ColorPicker, Props } from "../ColorPicker";
import { defaultColorPickerStyle } from "../ui/Styles";

describe("Color Picker", () => {
let defaultProps: Props;
Expand Down Expand Up @@ -177,6 +178,11 @@ describe("Color Picker", () => {
function getSliders(component: RenderAPI): ReactTestInstance[] {
return component.UNSAFE_getAllByType(Slider);
}

it("preserves expected style key set", () => {
const keys = Object.keys(defaultColorPickerStyle).sort();
expect(keys).toEqual(["container", "preview"]);
});
});

function responderMove(dx: number): any {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { aggregateGridPadding, mapToAxisStyle, mapToGridStyle, mapToColumnStyles } from "../StyleUtils";
import { ColumnChartAxisStyle, ColumnChartGridStyle, ColumnChartStyle } from "../../ui/Styles";
import { ColumnChartAxisStyle, ColumnChartGridStyle, ColumnChartStyle, defaultColumnChartStyle } from "../../ui/Styles";

describe("StyleMappers", () => {
describe("mapToGridStyle", () => {
Expand Down Expand Up @@ -210,3 +210,10 @@ describe("aggregateGridPadding", () => {
expect(aggregateGridPadding(undefined)).toBeUndefined();
});
});

describe("Style schema guardrail", () => {
it("preserves expected style key set", () => {
const keys = Object.keys(defaultColumnChartStyle).sort();
expect(keys).toEqual(["chart", "container", "errorMessage", "legend", "xAxis"]);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FeedbackStyle } from "../ui/styles";
import { FeedbackStyle, defaultFeedbackStyle } from "../ui/styles";
import { render, cleanup, fireEvent, waitFor } from "@testing-library/react-native";
import { FeedbackProps } from "../../typings/FeedbackProps";
import { Feedback } from "../Feedback";
Expand Down Expand Up @@ -95,4 +95,19 @@ describe("Feedback", () => {
expect(typeof body.metadata.screenWidth).toBe("number");
expect(typeof body.metadata.screenHeight).toBe("number");
}, 15000);

it("preserves expected style key set", () => {
const keys = Object.keys(defaultFeedbackStyle).sort();
expect(keys).toEqual([
"activityIndicator",
"button",
"buttonDisabled",
"dialog",
"floatingButton",
"switchInput",
"switchLabel",
"textAreaInput",
"title"
]);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { aggregateGridPadding, mapToAxisStyle, mapToGridStyle, mapToLineStyle, mapToMarkerStyle } from "../StyleUtils";
import { LineChartAxisStyle, LineChartGridStyle, LineChartLineStyle } from "../../ui/Styles";
import { LineChartAxisStyle, LineChartGridStyle, LineChartLineStyle, defaultLineChartStyle } from "../../ui/Styles";

describe("StyleMappers", () => {
describe("mapToGridStyle", () => {
Expand Down Expand Up @@ -183,3 +183,10 @@ describe("aggregateGridPadding", () => {
expect(aggregateGridPadding(undefined)).toBeUndefined();
});
});

describe("Style schema guardrail", () => {
it("preserves expected style key set", () => {
const keys = Object.keys(defaultLineChartStyle).sort();
expect(keys).toEqual(["chart", "container", "errorMessage", "grid", "legend", "xAxis"]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ describe("PieDoughnutChart", () => {
});
});
});

it("preserves expected style key set", () => {
const keys = Object.keys(defaultStyle).sort();
expect(keys).toEqual(["container", "slices"]);
});
});

function createProps(opts: Partial<PieDoughnutChartProps<ChartStyle>> = {}): PieDoughnutChartProps<ChartStyle> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Bar } from "react-native-progress";
import { render } from "@testing-library/react-native";

import { ProgressBar, Props } from "../ProgressBar";
import { defaultProgressBarStyle } from "../ui/Styles";

describe("ProgressBar", () => {
it("renders", () => {
Expand Down Expand Up @@ -45,6 +46,11 @@ describe("ProgressBar", () => {
expect(component.UNSAFE_getByType(Bar).props.progress).toBe(0.7);
expect(component.UNSAFE_queryByType(Text)).toBeNull();
});

it("preserves expected style key set", () => {
const keys = Object.keys(defaultProgressBarStyle).sort();
expect(keys).toEqual(["bar", "container", "fill", "validationMessage"]);
});
});

function createProps(progressValue?: number, minimumValue?: number, maximumValue?: number): Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Circle } from "react-native-progress";
import { render } from "@testing-library/react-native";

import { ProgressCircle, Props } from "../ProgressCircle";
import { defaultProgressCircleStyle } from "../ui/Styles";

describe("ProgressCircle", () => {
it("renders", () => {
Expand Down Expand Up @@ -80,6 +81,11 @@ No current value provided.`
const component = render(<ProgressCircle {...createProps(50, 0, 100)} circleText={"none"} />);
expect(component.UNSAFE_queryByType(Text)).toBeNull();
});

it("preserves expected style key set", () => {
const keys = Object.keys(defaultProgressCircleStyle).sort();
expect(keys).toEqual(["circle", "container", "fill", "text", "validationMessage"]);
});
});

function createProps(progressValue?: number, minimumValue?: number, maximumValue?: number): Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Text } from "react-native";
import { fireEvent, render } from "@testing-library/react-native";

import { Props, ToggleButtons } from "../ToggleButtons";
import { defaultToggleButtonsStyle } from "../ui/Styles";

describe("ToggleButtons", () => {
let defaultProps: Props;
Expand Down Expand Up @@ -68,4 +69,17 @@ describe("ToggleButtons", () => {

expect(defaultProps.enum.setValue).not.toHaveBeenCalled();
});

it("preserves expected style key set", () => {
const keys = Object.keys(defaultToggleButtonsStyle).sort();
expect(keys).toEqual([
"activeButton",
"activeButtonText",
"button",
"container",
"containerDisabled",
"text",
"validationMessage"
]);
});
});
Loading