Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 034ff6d

Browse files
committedSep 21, 2023
Testing in readOptions: augmentOptionsWithExcludes
1 parent 642714a commit 034ff6d

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed
 

Diff for: ‎src/shared/options/readOptions.test.ts

+35-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ vi.mock("../cli/spinners.ts", () => ({
4646
},
4747
}));
4848

49+
const mockAugmentOptionsWithExcludes = vi.fn();
50+
4951
vi.mock("./augmentOptionsWithExcludes.js", () => ({
50-
augmentOptionsWithExcludes() {
51-
return { ...emptyOptions, ...mockOptions };
52+
get augmentOptionsWithExcludes() {
53+
return mockAugmentOptionsWithExcludes;
5254
},
55+
// return { ...emptyOptions, ...mockOptions };
5356
}));
5457

5558
const mockDetectEmailRedundancy = vi.fn();
@@ -263,7 +266,37 @@ describe("readOptions", () => {
263266
});
264267
});
265268

269+
it("returns a cancellation when augmentOptionsWithExcludes returns undefined", async () => {
270+
mockDetectEmailRedundancy.mockReturnValue(false);
271+
mockGetPrefillOrPromptedOption
272+
.mockImplementationOnce(() => "MockOwner")
273+
.mockImplementationOnce(() => "MockRepository")
274+
.mockImplementationOnce(() => "Mock description.")
275+
.mockImplementationOnce(() => "Mock title.")
276+
.mockImplementation(() => undefined);
277+
mockEnsureRepositoryExists.mockResolvedValue({
278+
github: mockOptions.github,
279+
repository: mockOptions.repository,
280+
});
281+
mockAugmentOptionsWithExcludes.mockResolvedValue(undefined);
282+
283+
expect(await readOptions([])).toStrictEqual({
284+
cancelled: true,
285+
options: {
286+
...emptyOptions,
287+
description: "Mock description.",
288+
owner: "MockOwner",
289+
repository: "MockRepository",
290+
title: "Mock title.",
291+
},
292+
});
293+
});
294+
266295
it("returns success options when --base is valid", async () => {
296+
mockAugmentOptionsWithExcludes.mockResolvedValue({
297+
...emptyOptions,
298+
...mockOptions,
299+
});
267300
mockGetPrefillOrPromptedOption.mockImplementation(() => "mock");
268301

269302
expect(await readOptions(["--base", mockOptions.base])).toStrictEqual({

0 commit comments

Comments
 (0)
Please sign in to comment.