"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const problemPrompt_1 = __importDefault(require("./problemPrompt"));
const getProblems_1 = __importDefault(require("./utils/getProblems"));
const showProblem_1 = __importDefault(require("./showProblem"));
const inquirerWrapper_1 = __importDefault(require("./utils/inquirerWrapper"));
jest.mock('./utils/getProblems', () => jest.fn());
jest.mock('./showProblem', () => jest.fn());
jest.mock('./utils/inquirerWrapper', () => jest.fn());
describe('problemPrompt', () => {
    const getProblemsMock = getProblems_1.default;
    const inquirerWrapperMock = inquirerWrapper_1.default;
    const showProblemMock = showProblem_1.default;
    const category = 'category';
    const problems = ['problem'];
    afterEach(() => {
        jest.resetAllMocks();
    });
    it('should pick the right problem', async () => {
        getProblemsMock.mockReturnValue({ category: problems });
        showProblemMock.mockResolvedValueOnce(undefined);
        inquirerWrapperMock
            .mockResolvedValueOnce({ category })
            .mockResolvedValueOnce({ problem: problems[0] })
            .mockResolvedValueOnce({ category: 'exit' });
        await (0, problemPrompt_1.default)();
        expect(showProblem_1.default).toHaveBeenCalledWith(problems[0]);
    });
    it('should exit when "exit" is selected', async () => {
        getProblemsMock.mockReturnValue({ category: [...problems, 'exit'] });
        inquirerWrapperMock.mockResolvedValueOnce({ category: 'exit' });
        await (0, problemPrompt_1.default)();
        expect(showProblem_1.default).not.toHaveBeenCalled();
    });
    it('should go back to recursively select problem when "back" is selected', async () => {
        console.clear = jest.fn();
        getProblemsMock.mockReturnValue({ category: [...problems] });
        showProblemMock.mockResolvedValueOnce(undefined);
        inquirerWrapperMock
            .mockResolvedValueOnce({ category })
            .mockResolvedValueOnce({ problem: 'back' })
            .mockResolvedValueOnce({ category })
            .mockResolvedValueOnce({ problem: problems[0] })
            .mockResolvedValueOnce({ category: 'exit' });
        await (0, problemPrompt_1.default)();
        expect(showProblem_1.default).toHaveBeenCalledTimes(1);
        expect(showProblem_1.default).toHaveBeenCalledWith(problems[0]);
    });
});
