"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const enzyme_1 = require("enzyme");
const React = require("react");
const editor_1 = require("../../../../editor");
const util_1 = require("../../../../util");
const boxes_1 = require("../../../../editor/components/boxes");
const CoreTestActions_1 = require("../../../testeditor/CoreTestActions");
const CoreTestContext_1 = require("../../../testeditor/CoreTestContext");
const CoreTestProjection_1 = require("../../../testeditor/CoreTestProjection");
describe("TextComponent", () => {
    let nextLeaf;
    let text = "hello projectit";
    let editor;
    let textbox;
    beforeEach(() => {
        util_1.PiLogger.muteAllLogs();
        const context = new CoreTestContext_1.CoreTestContext(null);
        const action = new CoreTestActions_1.CoreTestActions();
        const projection = new CoreTestProjection_1.CoreTestProjection();
        editor = new editor_1.PiEditor(projection, action);
        editor.rootElement = context.rootElement;
        nextLeaf = new editor_1.AliasBox(context.rootElement, "", "");
        textbox = new editor_1.TextBox(context.rootElement, "", () => text, t => {
            text = t;
        });
    });
    it("should render the given box", () => {
        const component = enzyme_1.mount(React.createElement(boxes_1.TextComponent, Object.assign({}, { box: textbox, editor: editor })));
        expect(component.text()).toBe(text);
    });
    it("should not be editable and not have focus by default", () => {
        const component = enzyme_1.mount(React.createElement(boxes_1.TextComponent, Object.assign({}, { box: textbox, editor: editor })));
        expect(hasFocus(component)).toBeFalsy();
    });
});
function hasFocus(component) {
    return component.getDOMNode() === document.activeElement;
}
//# sourceMappingURL=TextComponent.spec.js.map