More tests
parent
13f05691cb
commit
4e1a7fe81e
|
@ -0,0 +1,34 @@
|
|||
import {
|
||||
isNumericSetting,
|
||||
isBooleanSetting,
|
||||
safeBooleanSettting,
|
||||
safeNumericSetting
|
||||
} from "../session";
|
||||
|
||||
describe("isNumericSetting", () => {
|
||||
it("determines numericality", () => {
|
||||
expect(isNumericSetting("zoomLevel")).toBe(true);
|
||||
expect(isNumericSetting("foo")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isBooleanSetting", () => {
|
||||
it("determines boolean-ness of settings", () => {
|
||||
expect(isBooleanSetting("xAxisInverted")).toBe(true);
|
||||
expect(isBooleanSetting("no")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("safeBooleanSetting", () => {
|
||||
it("safely fetches bool", () => {
|
||||
expect(() => safeBooleanSettting("NO")).toThrow();
|
||||
expect(safeBooleanSettting("xAxisInverted")).toBe("xAxisInverted");
|
||||
});
|
||||
});
|
||||
|
||||
describe("safeNumericSetting", () => {
|
||||
it("safely returns num", () => {
|
||||
expect(() => safeNumericSetting("NO")).toThrow();
|
||||
expect(safeNumericSetting("zoomLevel")).toBe("zoomLevel");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
import { authReducer } from "../reducer";
|
||||
import { setToken } from "../actions";
|
||||
import { AuthState } from "../interfaces";
|
||||
|
||||
describe("Auth reducer", () => {
|
||||
function fakeToken(): AuthState {
|
||||
const output: Partial<AuthState> = {
|
||||
token: ({} as any)
|
||||
};
|
||||
return output as AuthState;
|
||||
}
|
||||
|
||||
it("replaces the token", () => {
|
||||
const result = authReducer({ token: undefined }, setToken(fakeToken()));
|
||||
expect(result.token).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -30,6 +30,7 @@ import { fakeState } from "../../__test_support__/fake_state";
|
|||
import { changeStepSize, resetNetwork, resetConnectionInfo } from "../actions";
|
||||
import { Actions } from "../../constants";
|
||||
import { fakeDevice } from "../../__test_support__/resource_index_builder";
|
||||
import { API } from "../../api/index";
|
||||
|
||||
describe("checkControllerUpdates()", function () {
|
||||
beforeEach(function () {
|
||||
|
@ -226,9 +227,10 @@ describe("resetConnectionInfo()", () => {
|
|||
it("dispatches the right actions", () => {
|
||||
const mock1 = jest.fn();
|
||||
const d = fakeDevice();
|
||||
API.setBaseUrl("http://localhost:300");
|
||||
resetConnectionInfo(d)(mock1, jest.fn());
|
||||
expect(mock1).toHaveBeenCalledWith(resetNetwork());
|
||||
expect(mock1).toHaveBeenCalledTimes(2);
|
||||
expect(mock1).toHaveBeenCalledTimes(1);
|
||||
expect(mockDevice.readStatus).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -73,7 +73,7 @@ export namespace Session {
|
|||
}
|
||||
}
|
||||
|
||||
const isBooleanSetting =
|
||||
export const isBooleanSetting =
|
||||
// tslint:disable-next-line:no-any
|
||||
(x: any): x is BooleanSetting => !!BooleanSetting[x];
|
||||
|
||||
|
@ -85,7 +85,7 @@ export function safeBooleanSettting(name: string): BooleanSetting {
|
|||
}
|
||||
}
|
||||
|
||||
const isNumericSetting =
|
||||
export const isNumericSetting =
|
||||
// tslint:disable-next-line:no-any
|
||||
(x: any): x is NumericSetting => !!NumericSetting[x];
|
||||
|
||||
|
|
Loading…
Reference in New Issue