type errors
parent
392c8ef6e0
commit
4c7945f8e1
|
@ -5,8 +5,7 @@ jest.mock("farmbot", () => {
|
|||
return { Farmbot: mockFarmbot };
|
||||
});
|
||||
|
||||
import { fetchNewDevice, getDevice } from "../device";
|
||||
import { auth } from "../__test_support__/fake_state/token";
|
||||
import { getDevice } from "../device";
|
||||
|
||||
describe("getDevice()", () => {
|
||||
it("crashes if you call getDevice() too soon in the app lifecycle", () => {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
jest.mock("../device", () => {
|
||||
return { getDevice: () => ({ publish: jest.fn() }) };
|
||||
});
|
||||
|
||||
import { isSafeError, inferUpdateId } from "../interceptor_support";
|
||||
|
||||
describe("isSafeError", () => {
|
||||
|
@ -14,4 +18,8 @@ describe("inferUpdateId", () => {
|
|||
expect(inferUpdateId("foo/123/456")).toBe("*");
|
||||
expect(inferUpdateId((true as any))).toBe("*");
|
||||
});
|
||||
|
||||
it("handles normal URLs", () => {
|
||||
expect(inferUpdateId("foo/123")).toBe("123");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -53,16 +53,18 @@ interface DataUpdateEndOfLife {
|
|||
export function notifyBotOfChanges(url: string | undefined,
|
||||
action: DataChangeType, uuid: string) {
|
||||
if (url) {
|
||||
url.split("/").filter((chunk: ResourceName) => {
|
||||
return RESOURNCE_NAME_IN_URL.includes(chunk);
|
||||
}).map(async function (resource: ResourceName) {
|
||||
const data_update: DataUpdateEndOfLife = {
|
||||
kind: "data_update",
|
||||
args: { value: action },
|
||||
body: toPairs({ [resource]: inferUpdateId(url) })
|
||||
};
|
||||
getDevice().publish(rpcRequest([data_update as any]));
|
||||
});
|
||||
url
|
||||
.split("/")
|
||||
.filter((chunk: ResourceName) => {
|
||||
return RESOURNCE_NAME_IN_URL.includes(chunk);
|
||||
}).map(async function (resource: ResourceName) {
|
||||
const data_update: DataUpdateEndOfLife = {
|
||||
kind: "data_update",
|
||||
args: { value: action },
|
||||
body: toPairs({ [resource]: inferUpdateId(url) })
|
||||
};
|
||||
getDevice().publish(rpcRequest([data_update as any]));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue