Skip to content

Commit c6c7b71

Browse files
committed
Add test for renaming expanded items
1 parent 0bccdbb commit c6c7b71

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,47 @@ describe("db manager", () => {
423423

424424
expect(expandedItems?.length).toEqual(0);
425425
});
426+
427+
it("should rename item in expanded state", async () => {
428+
// Add item to config
429+
const listName = "my-list-3";
430+
const dbConfig = createDbConfig({
431+
remoteLists: [{ name: listName, repositories: [] }],
432+
});
433+
await saveDbConfig(dbConfig);
434+
435+
// Add item to expanded state
436+
const variantAnalysisList = {
437+
kind: ExpandedDbItemKind.RemoteUserDefinedList,
438+
listName,
439+
};
440+
441+
await app.workspaceState.update(DbManager.DB_EXPANDED_STATE_KEY, [
442+
variantAnalysisList,
443+
]);
444+
let expandedItems = await app.workspaceState.get<ExpandedDbItem[]>(
445+
DbManager.DB_EXPANDED_STATE_KEY,
446+
);
447+
expect(expandedItems?.length).toEqual(1);
448+
let expandedItem =
449+
expandedItems![0] as VariantAnalysisUserDefinedListExpandedDbItem;
450+
expect(expandedItem.listName).toEqual(listName);
451+
452+
// Rename item
453+
const dbItem = createVariantAnalysisUserDefinedListDbItem({
454+
listName,
455+
});
456+
457+
await dbManager.renameList(dbItem, "new-list-name");
458+
expandedItems = await app.workspaceState.get<ExpandedDbItem[]>(
459+
DbManager.DB_EXPANDED_STATE_KEY,
460+
);
461+
462+
expect(expandedItems?.length).toEqual(1);
463+
expandedItem =
464+
expandedItems![0] as VariantAnalysisUserDefinedListExpandedDbItem;
465+
expect(expandedItem.listName).toEqual("new-list-name");
466+
});
426467
});
427468

428469
async function saveDbConfig(dbConfig: DbConfig): Promise<void> {

0 commit comments

Comments
 (0)