Skip to content

Commit 3eef0e9

Browse files
committed
Give modal methods their own describe blocks
1 parent 562f926 commit 3eef0e9

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

extensions/ql-vscode/test/vscode-tests/no-workspace/helpers.test.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ describe("helpers", () => {
416416
});
417417
});
418418

419-
describe("open dialog", () => {
419+
describe("showBinaryChoiceDialog", () => {
420420
let showInformationMessageSpy: jest.SpiedFunction<
421421
typeof window.showInformationMessage
422422
>;
@@ -445,6 +445,23 @@ describe("helpers", () => {
445445
const val = await showBinaryChoiceDialog("xxx");
446446
expect(val).toBe(false);
447447
});
448+
});
449+
450+
describe("showInformationMessageWithAction", () => {
451+
let showInformationMessageSpy: jest.SpiedFunction<
452+
typeof window.showInformationMessage
453+
>;
454+
455+
beforeEach(() => {
456+
showInformationMessageSpy = jest
457+
.spyOn(window, "showInformationMessage")
458+
.mockResolvedValue(undefined);
459+
});
460+
461+
const resolveArg =
462+
(index: number) =>
463+
(...args: any[]) =>
464+
Promise.resolve(args[index]);
448465

449466
it("should show an info dialog and confirm the action", async () => {
450467
// pretend user chooses to run action
@@ -459,6 +476,23 @@ describe("helpers", () => {
459476
const val = await showInformationMessageWithAction("xxx", "yyy");
460477
expect(val).toBe(false);
461478
});
479+
});
480+
481+
describe("showBinaryChoiceWithUrlDialog", () => {
482+
let showInformationMessageSpy: jest.SpiedFunction<
483+
typeof window.showInformationMessage
484+
>;
485+
486+
beforeEach(() => {
487+
showInformationMessageSpy = jest
488+
.spyOn(window, "showInformationMessage")
489+
.mockResolvedValue(undefined);
490+
});
491+
492+
const resolveArg =
493+
(index: number) =>
494+
(...args: any[]) =>
495+
Promise.resolve(args[index]);
462496

463497
it("should show a binary choice dialog with a url and return `yes`", async () => {
464498
// pretend user clicks on the url twice and then clicks 'yes'

0 commit comments

Comments
 (0)