Skip to content

Commit bb1bd5c

Browse files
Add test for when there are no databases
1 parent dd98a96 commit bb1bd5c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

extensions/ql-vscode/test/vscode-tests/no-workspace/databases/local-databases-ui.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,29 @@ describe("local-databases-ui", () => {
246246
expect(showQuickPickSpy).toHaveBeenCalledTimes(2);
247247
expect(handleChooseDatabaseGithubSpy).toHaveBeenCalledTimes(1);
248248
});
249+
250+
it("should skip straight to prompting to import a database if there are no existing databases", async () => {
251+
databaseManager.databaseItems = [];
252+
253+
const showQuickPickSpy = jest
254+
.spyOn(window, "showQuickPick")
255+
.mockResolvedValueOnce(
256+
mockedQuickPickItem(
257+
mockedObject<DatabaseImportQuickPickItems>({
258+
importType: "github",
259+
}),
260+
),
261+
);
262+
263+
const handleChooseDatabaseGithubSpy = jest
264+
.spyOn(databaseUI as any, "handleChooseDatabaseGithub")
265+
.mockResolvedValue(undefined);
266+
267+
await databaseUI.getDatabaseItem(progress, token);
268+
269+
expect(showQuickPickSpy).toHaveBeenCalledTimes(1);
270+
expect(handleChooseDatabaseGithubSpy).toHaveBeenCalledTimes(1);
271+
});
249272
});
250273
});
251274

0 commit comments

Comments
 (0)