fix(settings): fix unit test
This commit is contained in:
parent
f151f47581
commit
1fa868ed95
5 changed files with 23 additions and 12 deletions
|
@ -65,6 +65,10 @@ export interface ListSharingsResp {
|
|||
sharingDirs: string[];
|
||||
}
|
||||
|
||||
export interface ClientConfigMsg {
|
||||
clientCfg: ClientConfig;
|
||||
}
|
||||
|
||||
export interface ClientConfig {
|
||||
siteName: string;
|
||||
siteDesc: string;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// TODO: replace this with jest mocks
|
||||
import { Response, Quota } from ".";
|
||||
import { Response } from ".";
|
||||
|
||||
import { ClientConfig } from "./";
|
||||
import { ClientConfigMsg } from "./";
|
||||
|
||||
export interface SettingsClientResps {
|
||||
healthMockResp?: Response;
|
||||
setClientCfgMockResp?: Response;
|
||||
getClientCfgMockResp?: Response<ClientConfig>;
|
||||
getClientCfgMockResp?: Response<ClientConfigMsg>;
|
||||
}
|
||||
|
||||
export const resps = {
|
||||
|
@ -16,6 +16,7 @@ export const resps = {
|
|||
status: 200,
|
||||
statusText: "",
|
||||
data: {
|
||||
clientCfg: {
|
||||
siteName: "",
|
||||
siteDesc: "",
|
||||
bg: {
|
||||
|
@ -24,6 +25,7 @@ export const resps = {
|
|||
position: "",
|
||||
align: "",
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -17,6 +17,7 @@ describe("Panes", () => {
|
|||
panes: coreState.panes,
|
||||
admin: coreState.admin,
|
||||
login: coreState.login,
|
||||
ui: coreState.ui,
|
||||
msg: coreState.msg,
|
||||
update: (updater: (prevState: ICoreState) => ICoreState) => {},
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ import { initUploadMgr } from "../../worker/upload_mgr";
|
|||
import { User, UploadInfo } from "../../client";
|
||||
import { MockFilesClient, resps as filesResps } from "../../client/files_mock";
|
||||
import { MockUsersClient, resps as usersResps } from "../../client/users_mock";
|
||||
import { MockSettingsClient, resps as settingsResps } from "../../client/settings_mock";
|
||||
import { ICoreState, newState } from "../core_state";
|
||||
import { MockWorker, UploadState, UploadEntry } from "../../worker/interface";
|
||||
|
||||
|
@ -13,6 +14,7 @@ describe("State Manager", () => {
|
|||
test("initUpdater for admin", async () => {
|
||||
const usersCl = new MockUsersClient("");
|
||||
const filesCl = new MockFilesClient("");
|
||||
const settingsCl = new MockSettingsClient("");
|
||||
|
||||
const mockWorkerClass = mock(MockWorker);
|
||||
const mockWorker = instance(mockWorkerClass);
|
||||
|
@ -21,6 +23,7 @@ describe("State Manager", () => {
|
|||
const mgr = new StateMgr({}); // it will call initUpdater
|
||||
mgr.setUsersClient(usersCl);
|
||||
mgr.setFilesClient(filesCl);
|
||||
mgr.setSettingsClient(settingsCl);
|
||||
|
||||
// TODO: depress warning
|
||||
mgr.update = (apply: (prevState: ICoreState) => ICoreState): void => {
|
||||
|
@ -98,6 +101,7 @@ describe("State Manager", () => {
|
|||
test("initUpdater for visitor in sharing mode", async () => {
|
||||
const usersCl = new MockUsersClient("");
|
||||
const filesCl = new MockFilesClient("");
|
||||
const settingsCl = new MockSettingsClient("");
|
||||
const mockSelfResp = {
|
||||
status: 200,
|
||||
statusText: "",
|
||||
|
@ -128,6 +132,7 @@ describe("State Manager", () => {
|
|||
const mgr = new StateMgr({}); // it will call initUpdater
|
||||
mgr.setUsersClient(usersCl);
|
||||
mgr.setFilesClient(filesCl);
|
||||
mgr.setSettingsClient(settingsCl);
|
||||
// TODO: depress warning
|
||||
mgr.update = (apply: (prevState: ICoreState) => ICoreState): void => {
|
||||
// no op
|
||||
|
|
|
@ -10,7 +10,6 @@ import { alertMsg } from "../common/env";
|
|||
export interface Props {
|
||||
login: LoginProps;
|
||||
msg: MsgProps;
|
||||
|
||||
update?: (updater: (prevState: ICoreState) => ICoreState) => void;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue