mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fixes
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
4dd6d587ab
commit
205864f66c
@ -10,7 +10,7 @@ jest.mock("electron", () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
import { WorkspaceStore } from "../workspace-store"
|
import { Workspace, WorkspaceStore } from "../workspace-store"
|
||||||
|
|
||||||
describe("workspace store tests", () => {
|
describe("workspace store tests", () => {
|
||||||
describe("for an empty config", () => {
|
describe("for an empty config", () => {
|
||||||
@ -35,16 +35,16 @@ describe("workspace store tests", () => {
|
|||||||
it("cannot remove the default workspace", () => {
|
it("cannot remove the default workspace", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
expect(() => ws.removeWorkspace(WorkspaceStore.defaultId)).toThrowError("Cannot remove");
|
expect(() => ws.removeWorkspaceById(WorkspaceStore.defaultId)).toThrowError("Cannot remove");
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can update default workspace name", () => {
|
it("can update default workspace name", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: WorkspaceStore.defaultId,
|
id: WorkspaceStore.defaultId,
|
||||||
name: "foobar",
|
name: "foobar",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(ws.currentWorkspace.name).toBe("foobar");
|
expect(ws.currentWorkspace.name).toBe("foobar");
|
||||||
})
|
})
|
||||||
@ -52,10 +52,10 @@ describe("workspace store tests", () => {
|
|||||||
it("can add workspaces", () => {
|
it("can add workspaces", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "123",
|
id: "123",
|
||||||
name: "foobar",
|
name: "foobar",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(ws.getById("123").name).toBe("foobar");
|
expect(ws.getById("123").name).toBe("foobar");
|
||||||
})
|
})
|
||||||
@ -69,10 +69,10 @@ describe("workspace store tests", () => {
|
|||||||
it("can set a existent workspace to be active", () => {
|
it("can set a existent workspace to be active", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "abc",
|
id: "abc",
|
||||||
name: "foobar",
|
name: "foobar",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(() => ws.setActive("abc")).not.toThrowError();
|
expect(() => ws.setActive("abc")).not.toThrowError();
|
||||||
})
|
})
|
||||||
@ -80,15 +80,15 @@ describe("workspace store tests", () => {
|
|||||||
it("can remove a workspace", () => {
|
it("can remove a workspace", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "123",
|
id: "123",
|
||||||
name: "foobar",
|
name: "foobar",
|
||||||
});
|
}));
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "1234",
|
id: "1234",
|
||||||
name: "foobar 1",
|
name: "foobar 1",
|
||||||
});
|
}));
|
||||||
ws.removeWorkspace("123");
|
ws.removeWorkspaceById("123");
|
||||||
|
|
||||||
expect(ws.workspaces.size).toBe(2);
|
expect(ws.workspaces.size).toBe(2);
|
||||||
})
|
})
|
||||||
@ -96,10 +96,10 @@ describe("workspace store tests", () => {
|
|||||||
it("cannot create workspace with existent name", () => {
|
it("cannot create workspace with existent name", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "someid",
|
id: "someid",
|
||||||
name: "default",
|
name: "default",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
||||||
})
|
})
|
||||||
@ -107,10 +107,10 @@ describe("workspace store tests", () => {
|
|||||||
it("cannot create workspace with empty name", () => {
|
it("cannot create workspace with empty name", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "random",
|
id: "random",
|
||||||
name: "",
|
name: "",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
||||||
})
|
})
|
||||||
@ -118,10 +118,10 @@ describe("workspace store tests", () => {
|
|||||||
it("cannot create workspace with ' ' name", () => {
|
it("cannot create workspace with ' ' name", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "random",
|
id: "random",
|
||||||
name: " ",
|
name: " ",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
||||||
})
|
})
|
||||||
@ -129,10 +129,10 @@ describe("workspace store tests", () => {
|
|||||||
it("trim workspace name", () => {
|
it("trim workspace name", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
ws.saveWorkspace({
|
ws.addWorkspace(new Workspace({
|
||||||
id: "random",
|
id: "random",
|
||||||
name: "default ",
|
name: "default ",
|
||||||
});
|
}));
|
||||||
|
|
||||||
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
expect(ws.workspacesList.length).toBe(1); // default workspace only
|
||||||
})
|
})
|
||||||
|
|||||||
@ -170,14 +170,13 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
addCluster(model: ClusterModel): Cluster {
|
addCluster(model: ClusterModel | Cluster ): Cluster {
|
||||||
appEventBus.emit({name: "cluster", action: "add"})
|
appEventBus.emit({name: "cluster", action: "add"})
|
||||||
let cluster: Cluster = null
|
let cluster = model as Cluster;
|
||||||
if (model instanceof Cluster === false) {
|
if (!(model instanceof Cluster)) {
|
||||||
cluster = new Cluster(model)
|
cluster = new Cluster(model)
|
||||||
}
|
}
|
||||||
this.clusters.set(model.id, cluster);
|
this.clusters.set(model.id, cluster);
|
||||||
|
|
||||||
return cluster
|
return cluster
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user