UNPKG

react-native-web-internals

Version:

React Native for Web

153 lines (152 loc) 5.77 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod )); var import__ = __toESM(require("..")), createProps = function(props) { return (0, import__.default)(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.js.map