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

useEditableValue-test.js — react Source File

Architecture documentation for useEditableValue-test.js, a javascript file in the react codebase. 1 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  35a311fd_6ea3_dde0_49bc_d09f74254507["useEditableValue-test.js"]
  7ea1760e_9c01_71c9_3ba5_32a9a10a0ce4["utils.js"]
  35a311fd_6ea3_dde0_49bc_d09f74254507 --> 7ea1760e_9c01_71c9_3ba5_32a9a10a0ce4
  style 35a311fd_6ea3_dde0_49bc_d09f74254507 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

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.
 *
 * @flow
 */

import {getVersionedRenderImplementation} from './utils';

describe('useEditableValue', () => {
  let act;
  let React;
  let useEditableValue;

  beforeEach(() => {
    const utils = require('./utils');
    act = utils.act;

    React = require('react');

    useEditableValue = require('../devtools/views/hooks').useEditableValue;
  });

  const {render} = getVersionedRenderImplementation();

  it('should not cause a loop with values like NaN', () => {
    let state;

    function Example({value = NaN}) {
      const tuple = useEditableValue(value);
      state = tuple[0];
      return null;
    }

    act(() => render(<Example />));

    expect(state.editableValue).toEqual('NaN');
    expect(state.externalValue).toEqual(NaN);
    expect(state.parsedValue).toEqual(NaN);
    expect(state.hasPendingChanges).toBe(false);
    expect(state.isValid).toBe(true);
  });

  it('should override editable state when external props are updated', () => {
    let state;

    function Example({value}) {
      const tuple = useEditableValue(value);
      state = tuple[0];
      return null;
    }

    act(() => render(<Example value={1} />));

    expect(state.editableValue).toEqual('1');
    expect(state.externalValue).toEqual(1);
    expect(state.parsedValue).toEqual(1);
    expect(state.hasPendingChanges).toBe(false);
// ... (136 more lines)

Domain

Dependencies

Frequently Asked Questions

What does useEditableValue-test.js do?
useEditableValue-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does useEditableValue-test.js depend on?
useEditableValue-test.js imports 1 module(s): utils.js.
Where is useEditableValue-test.js in the architecture?
useEditableValue-test.js is located at packages/react-devtools-shared/src/__tests__/useEditableValue-test.js (domain: BabelCompiler, directory: packages/react-devtools-shared/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free