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

utils-test.js — react Source File

Architecture documentation for utils-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.
 *
 * @flow
 */

describe('Stylex plugin utils', () => {
  let getStyleXData;
  let styleElements;

  function defineStyles(style) {
    const styleElement = document.createElement('style');
    styleElement.type = 'text/css';
    styleElement.appendChild(document.createTextNode(style));

    styleElements.push(styleElement);

    document.head.appendChild(styleElement);
  }

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

    styleElements = [];
  });

  afterEach(() => {
    styleElements.forEach(styleElement => {
      document.head.removeChild(styleElement);
    });
  });

  it('should gracefully handle empty values', () => {
    expect(getStyleXData(null)).toMatchInlineSnapshot(`
      {
        "resolvedStyles": {},
        "sources": [],
      }
    `);

    expect(getStyleXData(undefined)).toMatchInlineSnapshot(`
      {
        "resolvedStyles": {},
        "sources": [],
      }
    `);

    expect(getStyleXData('')).toMatchInlineSnapshot(`
      {
        "resolvedStyles": {},
        "sources": [],
      }
    `);

    expect(getStyleXData([undefined])).toMatchInlineSnapshot(`
      {
        "resolvedStyles": {},
// ... (202 more lines)

Frequently Asked Questions

What does utils-test.js do?
utils-test.js is a source file in the react codebase, written in javascript.
Where is utils-test.js in the architecture?
utils-test.js is located at packages/react-devtools-shared/src/backend/StyleX/__tests__/utils-test.js (directory: packages/react-devtools-shared/src/backend/StyleX/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free