UNPKG

react-native-web-internals

Version:

React Native for Web

140 lines (139 loc) 4.7 kB
import createDOMProps from ".."; var createProps = function (props) { return createDOMProps(null, props); }; describe("modules/createDOMProps", function () { describe("focus-related accessibility attributes", function () { test("with no accessibility props", function () { expect(createProps({})).toEqual({}); }), describe('"accessibilityRole" of "link"', function () { var accessibilityRole = "link"; test("default case", function () { expect(createProps({ accessibilityRole })).toEqual(expect.not.objectContaining({ tabIndex: "-1" })); }), test('when "focusable" is true', function () { expect(createProps({ accessibilityRole, focusable: !0 })).toEqual(expect.not.objectContaining({ tabIndex: "-1" })); }), test('when "focusable" is false', function () { expect(createProps({ accessibilityRole, focusable: !1 })).toEqual(expect.objectContaining({ tabIndex: "-1" })); }), test('when "accessibilityDisabled" is true', function () { expect(createProps({ accessibilityRole, accessibilityDisabled: !0 })).toEqual(expect.objectContaining({ "aria-disabled": !0 })); }), test('when "disabled" is false', function () { expect(createProps({ accessibilityRole, accessibilityDisabled: !1 })).toEqual(expect.not.objectContaining({ tabIndex: "-1" })); }); }); var testFocusableRole = function (accessibilityRole) { test("default case", function () { expect(createProps({ accessibilityRole })).toEqual(expect.objectContaining({ tabIndex: "0" })); }), test('when "focusable" is true', function () { expect(createProps({ accessibilityRole, focusable: !0 })).toEqual(expect.objectContaining({ tabIndex: "0" })); }), test('when "focusable" is false', function () { expect(createProps({ accessibilityRole, focusable: !1 })).toEqual(expect.objectContaining({ tabIndex: "-1" })); }), test('when "accessibilityDisabled" is true', function () { expect(createProps({ accessibilityRole, accessibilityDisabled: !0 })).toEqual(expect.objectContaining({ "aria-disabled": !0 })); }), test('when "accessibilityDisabled" is false', function () { expect(createProps({ accessibilityRole, accessibilityDisabled: !1 })).toEqual(expect.objectContaining({ tabIndex: "0" })); }); }; describe('"accessibilityRole" of "button"', function () { testFocusableRole("button"); }), describe("with unfocusable accessibilityRole", function () { test('when "focusable" is true', function () { expect(createProps({ focusable: !0 })).toEqual(expect.objectContaining({ tabIndex: "0" })); }), test('when "focusable" is false', function () { expect(createProps({ focusable: !1 })).toEqual(expect.objectContaining({ tabIndex: "-1" })); }); }); }), test('prop "accessibilityLabel" becomes "aria-label"', function () { var accessibilityLabel = "accessibilityLabel", props = createProps({ accessibilityLabel }); expect(props["aria-label"]).toEqual(accessibilityLabel); }), test('prop "accessibilityLiveRegion" becomes "aria-live"', function () { var accessibilityLiveRegion = "none", props = createProps({ accessibilityLiveRegion }); expect(props["aria-live"]).toEqual("off"); }), test('prop "accessibilityRole" becomes "role"', function () { var accessibilityRole = "button", props = createProps({ accessibilityRole }); expect(props.role).toEqual("button"); }), test('prop "className" is preserved', function () { var className = "external-class-name", props = createProps({ className }); expect(props.className).toEqual(className); }), test('prop "nativeID" becomes "id"', function () { var nativeID = "Example.nativeID", props = createProps({ nativeID }); expect(props.id).toEqual(nativeID); }), test('prop "testID" becomes "data-testid"', function () { var testID = "Example.testID", props = createProps({ testID }); expect(props["data-testid"]).toEqual(testID); }); }); //# sourceMappingURL=index-test.native.js.map