Home / File/ SyntheticKeyboardEvent-test.js — react Source File

SyntheticKeyboardEvent-test.js — react Source File

Architecture documentation for SyntheticKeyboardEvent-test.js, a javascript file in the react codebase.

Entity Profile

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @emails react-core
 */

'use strict';

let React;
let ReactDOMClient;

let act;

describe('SyntheticKeyboardEvent', () => {
  let container;
  let root;

  beforeEach(() => {
    React = require('react');
    ReactDOMClient = require('react-dom/client');

    act = require('internal-test-utils').act;

    // The container has to be attached for events to fire.
    container = document.createElement('div');
    root = ReactDOMClient.createRoot(container);
    document.body.appendChild(container);
  });

  afterEach(async () => {
    await act(() => {
      root.unmount();
    });
    document.body.removeChild(container);
    container = null;
  });

  describe('KeyboardEvent interface', () => {
    describe('charCode', () => {
      describe('when event is `keypress`', () => {
        describe('when charCode is present in nativeEvent', () => {
          it('when charCode is 0 and keyCode is 13, returns 13', async () => {
            let charCode = null;
            await act(() => {
              root.render(
                <input
                  onKeyPress={e => {
                    charCode = e.charCode;
                  }}
                />,
              );
            });
            container.firstChild.dispatchEvent(
              new KeyboardEvent('keypress', {
                charCode: 0,
                keyCode: 13,
                bubbles: true,
// ... (518 more lines)

Frequently Asked Questions

What does SyntheticKeyboardEvent-test.js do?
SyntheticKeyboardEvent-test.js is a source file in the react codebase, written in javascript.
Where is SyntheticKeyboardEvent-test.js in the architecture?
SyntheticKeyboardEvent-test.js is located at packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js (directory: packages/react-dom/src/events/__tests__).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free