-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[fika-cli] create -y flag for for fika command that a question
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import SERVICE_IDENTIFIER from "@/config/constants/identifiers"; | ||
import container from "@/config/ioc_config"; | ||
import { IPromptService } from "@/domain/service/i-prompt.service"; | ||
import promptly from "promptly"; | ||
const promptService = container.get<IPromptService>(SERVICE_IDENTIFIER.PromptService); | ||
|
||
beforeAll(async () => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
beforeEach(async()=>{ | ||
|
||
}); | ||
|
||
afterEach(async ()=>{ | ||
|
||
|
||
}) | ||
|
||
afterAll(() => { | ||
|
||
}); | ||
|
||
describe("1. test confirmAction", () => { | ||
test("1.1. test confirm action without flag", async () => { | ||
const spy = jest.spyOn(promptly, "confirm").mockImplementation(()=>Promise.resolve(false)); | ||
const answer = await promptService.confirmAction("any message"); | ||
expect(answer).toBe(false); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test("1.2. test confirm action with flag", async () => { | ||
promptService.setAcceptsAllPromptsAsYes(); | ||
const spy = jest.spyOn(promptly, "confirm").mockImplementation(()=>Promise.resolve(false)); | ||
const answer = await promptService.confirmAction("any message"); | ||
expect(answer).toBe(true); | ||
expect(spy).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |