Skip to content

Commit

Permalink
increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Nov 22, 2024
1 parent dcd46c7 commit 2bf05c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 2 additions & 4 deletions frontend/curves/templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ import { t } from "i18next";
import { Color, DropDownItem } from "../ui";
import { Curve } from "farmbot/dist/resources/api_resources";
import { TaggedCurve } from "farmbot";
import { PanelColor } from "../farm_designer/panel_header";

export enum CurveType {
water = "water",
spread = "spread",
height = "height",
}

export const curvePanelColor = (curve: TaggedCurve | undefined) => {
switch (curve?.body.type) {
export const curvePanelColor = (curve: TaggedCurve) => {
switch (curve.body.type) {
case CurveType.water: return Color.curveBlue;
case CurveType.spread: return Color.curveGreen;
case CurveType.height: return Color.curvePurple;
default: return PanelColor.gray;
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/error_boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ErrorBoundary extends React.Component<ErrorBoundaryProps, State> {

no = () => this.props.fallback || <Apology />;

ok = () => this.props.children || <div className={"no-children"} />;
ok = () => this.props.children;

render() { return (this.state.hasError ? this.no : this.ok)(); }
}
19 changes: 19 additions & 0 deletions frontend/farm_events/__tests__/edit_fe_form_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ jest.mock("../../api/crud", () => ({
overwrite: jest.fn(),
}));

let mockTzMismatch = false;
jest.mock("../../devices/timezones/guess_timezone", () => ({
timezoneMismatch: () => mockTzMismatch,
}));

import React from "react";
import {
fakeFarmEvent, fakeSequence, fakeRegimen, fakePlant,
Expand Down Expand Up @@ -167,6 +172,20 @@ describe("<EditFEForm />", () => {
expect(wrapper.html()).not.toContain("fa-exclamation-triangle");
});

it("doesn't show tz warning", () => {
mockTzMismatch = false;
const p = fakeProps();
const wrapper = mount(<EditFEForm {...p} />);
expect(wrapper.html()).not.toContain(Content.FARM_EVENT_TZ_WARNING);
});

it("shows tz warning", () => {
mockTzMismatch = true;
const p = fakeProps();
const wrapper = mount(<EditFEForm {...p} />);
expect(wrapper.html()).toContain(Content.FARM_EVENT_TZ_WARNING);
});

it("sets a subfield of state.fe", () => {
const p = fakeProps();
const i = instance(p);
Expand Down

0 comments on commit 2bf05c0

Please sign in to comment.