import { makeAppObjectRepo } from "@vived/core";
import { SubmitQuestionAnswerUC } from "../UC/SubmitQuestionAnswerUC";
import { submitQuestionAnswer } from "./submitQuestionAnswer";
class MockUC extends SubmitQuestionAnswerUC {
    constructor() {
        super(...arguments);
        this.submitAnswer = jest.fn();
    }
}
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const question = appObjects.getOrCreate("Question");
    const submitUC = new MockUC(question, SubmitQuestionAnswerUC.type);
    return { submitUC, appObjects };
}
describe("submitQuestionAnswer Controller", () => {
    it("Submits to the UC", () => {
        const { submitUC, appObjects } = makeTestRig();
        submitQuestionAnswer("an answer", appObjects);
        expect(submitUC.submitAnswer).toHaveBeenCalledWith("an answer");
    });
    it("Warns if it can't find the UC", () => {
        const { submitUC, appObjects } = makeTestRig();
        appObjects.submitWarning = jest.fn();
        submitUC.dispose();
        submitQuestionAnswer("an answer", appObjects);
        expect(appObjects.submitWarning).toHaveBeenCalled();
    });
});
//# sourceMappingURL=submitQuestionAnswer.test.js.map