[STABLE] ✔️
parent
b6ce6de8c6
commit
14ae7567c2
|
@ -1,4 +1,4 @@
|
|||
import { computeBestTime, getStatus, maxDate } from "../reducer_support";
|
||||
import { computeBestTime, getStatus } from "../reducer_support";
|
||||
import moment from "moment";
|
||||
import { ConnectionStatus } from "../interfaces";
|
||||
|
||||
|
@ -26,17 +26,6 @@ describe("computeBestTime()", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("maxDate()", () => {
|
||||
it("picks the max time, regardless of position", () => {
|
||||
expect(maxDate(moment(NOW), moment(LATER))).toBe(LATER_JSON);
|
||||
expect(maxDate(moment(LATER), moment(NOW))).toBe(LATER_JSON);
|
||||
});
|
||||
|
||||
it("picks dates[0] when there is a tie", () => {
|
||||
expect(maxDate(moment(LATER), moment(LATER))).toBe(LATER_JSON);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getStatus()", () => {
|
||||
it("returns 'down' when not given enough data", () => {
|
||||
expect(getStatus(undefined)).toBe("down");
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import { ConnectionStatus } from "./interfaces";
|
||||
import m from "moment";
|
||||
import { isString, max } from "lodash";
|
||||
|
||||
export function maxDate(l: m.Moment, r: m.Moment): string {
|
||||
const dates = [l, r].map(y => y.toDate());
|
||||
return (max(dates) || dates[0]).toJSON();
|
||||
}
|
||||
import { isString } from "lodash";
|
||||
|
||||
export function getStatus(cs: ConnectionStatus | undefined): "up" | "down" {
|
||||
return (cs && cs.state) || "down";
|
||||
|
|
|
@ -51,7 +51,7 @@ describe("<Devices/>", () => {
|
|||
p.botToMqtt = { at: 123, state: "up" };
|
||||
const wrapper = shallow(<Devices {...p} />);
|
||||
expect(wrapper.find(FarmbotOsSettings).props().botToMqttLastSeen)
|
||||
.toEqual("123");
|
||||
.toEqual(123);
|
||||
});
|
||||
|
||||
it("provides correct firmwareHardware value", () => {
|
||||
|
|
|
@ -56,7 +56,8 @@ describe("<LastSeen />", () => {
|
|||
p.device.body.last_saw_api = "2017-08-07T19:40:01.487Z";
|
||||
p.botToMqttLastSeen = new Date("2017-08-07T20:40:01.487Z").getTime();
|
||||
const wrapper = mount<LastSeen>(<LastSeen {...p} />);
|
||||
expect(wrapper.instance().lastSeen).toEqual("2017-08-07T20:40:01.487Z");
|
||||
const t = new Date("2017-08-07T20:40:01.487Z").getTime();
|
||||
expect(wrapper.instance().lastSeen).toEqual(t);
|
||||
});
|
||||
|
||||
it("handles a click", () => {
|
||||
|
|
Loading…
Reference in New Issue