Add test for set selected item
This commit is contained in:
@@ -3,6 +3,7 @@ import { join } from "path";
|
||||
import { App } from "../../../../src/common/app";
|
||||
import {
|
||||
DbConfig,
|
||||
SelectedDbItem,
|
||||
SelectedDbItemKind,
|
||||
} from "../../../../src/databases/config/db-config";
|
||||
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
|
||||
@@ -636,4 +637,40 @@ describe("db config store", () => {
|
||||
configStore.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
describe("set selected item", () => {
|
||||
let app: App;
|
||||
let configPath: string;
|
||||
|
||||
beforeEach(async () => {
|
||||
app = createMockApp({
|
||||
extensionPath,
|
||||
workspaceStoragePath: tempWorkspaceStoragePath,
|
||||
});
|
||||
|
||||
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
|
||||
});
|
||||
|
||||
it("should set the selected item", async () => {
|
||||
// Initial set up
|
||||
const configStore = new DbConfigStore(app);
|
||||
await configStore.initialize();
|
||||
|
||||
// Set selected
|
||||
const selectedItem: SelectedDbItem = {
|
||||
kind: SelectedDbItemKind.RemoteOwner,
|
||||
ownerName: "owner2",
|
||||
};
|
||||
|
||||
await configStore.setSelectedDbItem(selectedItem);
|
||||
|
||||
// Read the config file
|
||||
const updatedDbConfig = (await readJSON(configPath)) as DbConfig;
|
||||
|
||||
// Check that the config file has been updated
|
||||
expect(updatedDbConfig.selected).toEqual(selectedItem);
|
||||
|
||||
configStore.dispose();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user