Temporarily merge this stuff into staging

pull/925/head
Rick Carlino 2018-07-20 15:08:12 -05:00
parent 9c8daccbf3
commit 6239f6cf3e
3 changed files with 15 additions and 12 deletions

View File

@ -33,6 +33,8 @@ import { dispatchNetworkUp, dispatchNetworkDown } from "../connectivity";
import { error } from "farmbot-toastr";
import { Session } from "../session";
const A_STRING = expect.any(String);
interface FakeProps {
uuid: string;
method: string;
@ -67,7 +69,7 @@ describe("responseRejected", () => {
it("undefined error", async () => {
await expect(responseRejected(undefined)).rejects.toEqual(undefined);
expect(dispatchNetworkUp).not.toHaveBeenCalled();
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.api");
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.api", undefined, A_STRING);
});
it("safe error", async () => {
@ -77,7 +79,7 @@ describe("responseRejected", () => {
};
await expect(responseRejected(safeError)).rejects.toEqual(safeError);
expect(dispatchNetworkDown).not.toHaveBeenCalled();
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.api");
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.api", undefined, A_STRING);
});
it("handles 500", async () => {

View File

@ -52,6 +52,7 @@ import { fakeState } from "../../../__test_support__/fake_state";
import { talk } from "browser-speech";
import { globalQueue } from "../../batch_queue";
const A_STRING = expect.any(String);
describe("readStatus()", () => {
it("forces a read_status request to FarmBot", () => {
readStatus();
@ -156,8 +157,8 @@ describe("initLog", () => {
describe("bothUp()", () => {
it("marks MQTT and API as up", () => {
bothUp("tests");
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt");
expect(dispatchNetworkUp).toHaveBeenCalledWith("bot.mqtt");
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt", undefined, A_STRING);
expect(dispatchNetworkUp).toHaveBeenCalledWith("bot.mqtt", undefined, A_STRING);
});
});
@ -165,7 +166,7 @@ describe("onOffline", () => {
it("tells the app MQTT is down", () => {
jest.resetAllMocks();
onOffline();
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.mqtt");
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.mqtt", undefined, A_STRING);
expect(error).toHaveBeenCalledWith(Content.MQTT_DISCONNECTED, "Error");
});
});
@ -174,7 +175,7 @@ describe("onOnline", () => {
it("tells the app MQTT is up", () => {
jest.resetAllMocks();
onOnline();
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt");
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt", undefined, A_STRING);
});
});
@ -193,13 +194,13 @@ describe("onSent", () => {
it("marks MQTT as up", () => {
jest.resetAllMocks();
onSent({ connected: true })();
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt");
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt", undefined, A_STRING);
});
it("marks MQTT as down", () => {
jest.resetAllMocks();
onSent({ connected: false })();
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.mqtt");
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.mqtt", undefined, A_STRING);
});
});
@ -223,6 +224,6 @@ describe("onLogs", () => {
log.message = "bot xyz is offline";
fn(log);
globalQueue.maybeWork();
expect(dispatchNetworkDown).toHaveBeenCalledWith("bot.mqtt");
expect(dispatchNetworkDown).toHaveBeenCalledWith("bot.mqtt", undefined, A_STRING);
});
});

View File

@ -50,12 +50,12 @@ function fakeBot(): Farmbot {
}
function expectStale() {
expect(dispatchNetworkDown).toHaveBeenCalledWith("bot.mqtt");
expect(dispatchNetworkDown).toHaveBeenCalledWith("bot.mqtt", undefined, expect.any(String));
}
function expectActive() {
expect(dispatchNetworkUp).toHaveBeenCalledWith("bot.mqtt");
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt");
expect(dispatchNetworkUp).toHaveBeenCalledWith("bot.mqtt", undefined, expect.any(String));
expect(dispatchNetworkUp).toHaveBeenCalledWith("user.mqtt", undefined, expect.any(String));
}
describe("ping util", () => {