Remove some `any` types and upgrade FBJS

pull/982/head
Rick Carlino 2018-09-12 17:49:22 -05:00
parent 3af772910a
commit f52e60c2ff
7 changed files with 14 additions and 23 deletions

View File

@ -52,7 +52,7 @@
"css-loader": "1.0.0",
"enzyme": "3.6.0",
"enzyme-adapter-react-16": "1.5.0",
"farmbot": "https://github.com/RickCarlino/farmbot-js.git#2458c790",
"farmbot": "6.5.0",
"farmbot-toastr": "^1.0.3",
"fastclick": "^1.0.6",
"file-loader": "2.0.0",

View File

@ -1,10 +1,8 @@
import { ReactWrapper, ShallowWrapper } from "enzyme";
import { range } from "lodash";
// tslint:disable-next-line:no-any
export function getProp(i: ReactWrapper<any, {}>, key: string): any {
return i.props()[key];
}
export const getProp =
<T, K extends keyof T>(i: ReactWrapper<T, {}>, key: K): T[K] => i.props()[key];
/** Simulate a click and check button text for a button in a wrapper. */
export function clickButton(

View File

@ -7,13 +7,13 @@ jest.mock("farmbot", () => {
import { fetchNewDevice } from "../device";
import { auth } from "../__test_support__/fake_state/token";
import { get } from "lodash";
describe("fetchNewDevice", () => {
it("returns an instance of FarmBot", async () => {
const bot = await fetchNewDevice(auth);
expect(bot).toBeInstanceOf(mockFarmbot);
// We use this for debugging in local dev env
// tslint:disable-next-line:no-any
expect((global as any)["current_bot"]).toBeDefined();
expect(get(global, "current_bot")).toBeDefined();
});
});

View File

@ -1,7 +1,6 @@
const mock = {
response: {
// tslint:disable-next-line:no-any
data: (undefined as any) // Mutable
data: (undefined as undefined | {}) // Mutable
}
};
@ -35,8 +34,7 @@ describe("requestAccountExport", () => {
it("downloads the data synchronously (when API has no email support)", async () => {
mock.response.data = {};
// tslint:disable-next-line:no-any
window.URL = window.URL || ({} as any);
window.URL = window.URL || ({} as typeof window.URL);
window.URL.createObjectURL = jest.fn();
window.URL.revokeObjectURL = jest.fn();
const a = await requestAccountExport();

View File

@ -105,12 +105,9 @@ describe("<FbosDetails/>", () => {
it("doesn't display extra metrics when bot is offline", () => {
const p = fakeProps();
// tslint:disable-next-line:no-any
(p.botInfoSettings as any).uptime = undefined;
// tslint:disable-next-line:no-any
(p.botInfoSettings as any).memory_usage = undefined;
// tslint:disable-next-line:no-any
(p.botInfoSettings as any).disk_usage = undefined;
p.botInfoSettings.uptime = undefined;
p.botInfoSettings.memory_usage = undefined;
p.botInfoSettings.disk_usage = undefined;
const wrapper = mount(<FbosDetails {...p} />);
["uptime", "usage"].map(metric =>
expect(wrapper.text().toLowerCase()).not.toContain(metric));

View File

@ -64,9 +64,7 @@ export function FbosDetails(props: FbosDetailsProps) {
const {
env, commit, target, node_name, firmware_version, firmware_commit,
soc_temp, wifi_level, uptime, memory_usage, disk_usage
// TODO: remove `as any` in the next line (& tests) when FBJS is published.
// tslint:disable-next-line:no-any
} = botInfoSettings as any;
} = botInfoSettings;
const betaOptIn = sourceFbosConfig("beta_opt_in");
const shortenCommit = (longCommit: string) => (longCommit || "").slice(0, 8);
return <div>

View File

@ -2355,9 +2355,9 @@ farmbot-toastr@^1.0.0, farmbot-toastr@^1.0.3:
farmbot-toastr "^1.0.0"
typescript "^2.3.4"
"farmbot@https://github.com/RickCarlino/farmbot-js.git#2458c790":
version "6.5.0-rc7"
resolved "https://github.com/RickCarlino/farmbot-js.git#2458c790e27cb07df9c7aa4bc3e8a9cf2accb875"
farmbot@6.5.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/farmbot/-/farmbot-6.5.0.tgz#13b15161ea72c7f1d74676d33dbb8aec7d5db162"
dependencies:
mqtt "2.15.0"