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

SyntheticClipboardEvent-test.js — react Source File

Architecture documentation for SyntheticClipboardEvent-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('SyntheticClipboardEvent', () => {
  let container;

  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');
    document.body.appendChild(container);
  });

  afterEach(() => {
    document.body.removeChild(container);
    container = null;
  });

  describe('ClipboardEvent interface', () => {
    describe('clipboardData', () => {
      describe('when event has clipboardData', () => {
        it("returns event's clipboardData", async () => {
          let expectedCount = 0;

          // Mock clipboardData since jsdom implementation doesn't have a constructor
          const clipboardData = {
            dropEffect: null,
            effectAllowed: null,
            files: null,
            items: null,
            types: null,
          };
          const eventHandler = event => {
            expect(event.clipboardData).toBe(clipboardData);
            expectedCount++;
          };
          const root = ReactDOMClient.createRoot(container);
          await act(() => {
            root.render(
              <div
                onCopy={eventHandler}
                onCut={eventHandler}
                onPaste={eventHandler}
              />,
            );
// ... (77 more lines)

Frequently Asked Questions

What does SyntheticClipboardEvent-test.js do?
SyntheticClipboardEvent-test.js is a source file in the react codebase, written in javascript.
Where is SyntheticClipboardEvent-test.js in the architecture?
SyntheticClipboardEvent-test.js is located at packages/react-dom/src/events/__tests__/SyntheticClipboardEvent-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