"use strict";
/* tslint:disable:no-unused-variable */
var React = require("react");
/* tslint:enable:no-unused-variable */
var ReactDOM = require("react-dom");
var ReactTestUtils = require("react-addons-test-utils");
var expect = chai.expect;
var focus_1 = require("./focus");
var _hiddenElement;
var _visibleElement;
var _element;
function renderIntoDocument(element) {
    var component = ReactTestUtils.renderIntoDocument(element);
    var renderedDOM = ReactDOM.findDOMNode(component);
    return renderedDOM;
}
function _initialize() {
    _hiddenElement = renderIntoDocument(React.createElement("div", { "data-is-visible": false },
        React.createElement("button", null)));
    _visibleElement = renderIntoDocument(React.createElement("div", { "data-is-visible": true },
        React.createElement("button", null)));
    _element = renderIntoDocument(React.createElement("div", null,
        React.createElement("button", null)));
    _element.isVisible = true;
}
describe('isElementVisible', function () {
    beforeEach(function () { return _initialize(); });
    it('returns false if data-is-visible is false', function () {
        expect(focus_1.isElementVisible(_hiddenElement)).equals(false, 'Element is not visible');
    });
    it('returns true if data-is-visible is true', function () {
        expect(focus_1.isElementVisible(_visibleElement)).equals(true, 'Element is visible');
    });
    it('returns true if data-is-visible is undefined but element is visible', function () {
        expect(focus_1.isElementVisible(_element)).equals(true, 'Element is visible but data-is-visible is undefined');
    });
});
describe('isElementTabbable', function () {
    it('returns false on null', function () {
        expect(focus_1.isElementVisible(null)).is.false;
    });
    it('returns false on normal divs', function () {
        var div = document.createElement('div');
        expect(focus_1.isElementTabbable(div)).is.false;
    });
    it('returns false on disabled buttons', function () {
        var button = document.createElement('button');
        button.setAttribute('disabled', 'true');
        expect(focus_1.isElementTabbable(button)).is.false;
    });
    it('returns true on buttons', function () {
        var button = document.createElement('button');
        expect(focus_1.isElementTabbable(button)).is.true;
    });
    it('returns true on anchors', function () {
        var anchor = document.createElement('a');
        expect(focus_1.isElementTabbable(anchor)).is.true;
    });
    it('returns true on input elements', function () {
        var input = document.createElement('input');
        expect(focus_1.isElementTabbable(input)).is.true;
    });
    it('returns true on textarea elements', function () {
        var textarea = document.createElement('textarea');
        expect(focus_1.isElementTabbable(textarea)).is.true;
    });
    it('works with tabbable divs', function () {
        var div = document.createElement('div');
        div.tabIndex = 0;
        expect(focus_1.isElementTabbable(div)).is.true;
    });
    it('returns true with role=button divs', function () {
        var div = document.createElement('div');
        div.setAttribute('role', 'button');
        expect(focus_1.isElementTabbable(div)).is.true;
    });
    it('returns false with role=button disabled buttons', function () {
        var button = document.createElement('button');
        button.setAttribute('role', 'button');
        button.setAttribute('disabled', 'true');
        expect(focus_1.isElementTabbable(button)).is.false;
    });
});

//# sourceMappingURL=focus.test.js.map
