1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @emails react-core
    
  8.  */
    
  9. 
    
  10. 'use strict';
    
  11. 
    
  12. describe('ReactDOMInvalidARIAHook', () => {
    
  13.   let React;
    
  14.   let ReactTestUtils;
    
  15.   let mountComponent;
    
  16. 
    
  17.   beforeEach(() => {
    
  18.     jest.resetModules();
    
  19.     React = require('react');
    
  20.     ReactTestUtils = require('react-dom/test-utils');
    
  21. 
    
  22.     mountComponent = function (props) {
    
  23.       ReactTestUtils.renderIntoDocument(<div {...props} />);
    
  24.     };
    
  25.   });
    
  26. 
    
  27.   describe('aria-* props', () => {
    
  28.     it('should allow valid aria-* props', () => {
    
  29.       mountComponent({'aria-label': 'Bumble bees'});
    
  30.     });
    
  31.     it('should warn for one invalid aria-* prop', () => {
    
  32.       expect(() => mountComponent({'aria-badprop': 'maybe'})).toErrorDev(
    
  33.         'Warning: Invalid aria prop `aria-badprop` on <div> tag. ' +
    
  34.           'For details, see https://reactjs.org/link/invalid-aria-props',
    
  35.       );
    
  36.     });
    
  37.     it('should warn for many invalid aria-* props', () => {
    
  38.       expect(() =>
    
  39.         mountComponent({
    
  40.           'aria-badprop': 'Very tall trees',
    
  41.           'aria-malprop': 'Turbulent seas',
    
  42.         }),
    
  43.       ).toErrorDev(
    
  44.         'Warning: Invalid aria props `aria-badprop`, `aria-malprop` on <div> ' +
    
  45.           'tag. For details, see https://reactjs.org/link/invalid-aria-props',
    
  46.       );
    
  47.     });
    
  48.     it('should warn for an improperly cased aria-* prop', () => {
    
  49.       // The valid attribute name is aria-haspopup.
    
  50.       expect(() => mountComponent({'aria-hasPopup': 'true'})).toErrorDev(
    
  51.         'Warning: Unknown ARIA attribute `aria-hasPopup`. ' +
    
  52.           'Did you mean `aria-haspopup`?',
    
  53.       );
    
  54.     });
    
  55. 
    
  56.     it('should warn for use of recognized camel case aria attributes', () => {
    
  57.       // The valid attribute name is aria-haspopup.
    
  58.       expect(() => mountComponent({ariaHasPopup: 'true'})).toErrorDev(
    
  59.         'Warning: Invalid ARIA attribute `ariaHasPopup`. ' +
    
  60.           'Did you mean `aria-haspopup`?',
    
  61.       );
    
  62.     });
    
  63. 
    
  64.     it('should warn for use of unrecognized camel case aria attributes', () => {
    
  65.       // The valid attribute name is aria-haspopup.
    
  66.       expect(() => mountComponent({ariaSomethingInvalid: 'true'})).toErrorDev(
    
  67.         'Warning: Invalid ARIA attribute `ariaSomethingInvalid`. ARIA ' +
    
  68.           'attributes follow the pattern aria-* and must be lowercase.',
    
  69.       );
    
  70.     });
    
  71.   });
    
  72. });