How to use the react-cosmos-shared2/util.uuid function in react-cosmos-shared2

To help you get started, we’ve selected a few react-cosmos-shared2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-cosmos / react-cosmos / packages / react-cosmos-fixture / src / __tests__ / fixtureList.js View on Github external
// @flow

import { uuid } from 'react-cosmos-shared2/util';
import { runTests, mount } from '../testHelpers';

const rendererId = uuid();
const fixtures = { first: null, second: null };
const decorators = {};

runTests(mockConnect => {
  it('renders blank state message', async () => {
    await mockConnect(async ({ getElement }) => {
      await mount(
        getElement({ rendererId, fixtures, decorators }),
        async renderer => {
          expect(renderer.toJSON()).toEqual('No fixture loaded.');
        }
      );
    });
  });

  it('posts ready response on mount', async () => {
github react-cosmos / react-cosmos / packages / react-cosmos-fixture / src / __tests__ / childrenTransition.tsx View on Github external
import React from 'react';
import { uuid } from 'react-cosmos-shared2/util';
import { createValues, createValue } from 'react-cosmos-shared2/fixtureState';
import { anyProps } from '../testHelpers/fixtureState';
import { Wrapper } from '../testHelpers/components';
import { runFixtureLoaderTests } from '../testHelpers';

const rendererId = uuid();
const fixtures = {
  first: yo
};
const decorators = {};
const fixtureId = { path: 'first', name: null };

runFixtureLoaderTests(mount => {
  it('transitions string children into an element with children', async () => {
    await mount(
      { rendererId, fixtures, decorators },
      async ({ update, selectFixture, fixtureStateChange }) => {
        await selectFixture({
          rendererId,
          fixtureId,
          fixtureState: {}
        });
github react-cosmos / react-cosmos / packages / react-cosmos / src / dom / rendererId.ts View on Github external
function getRendererId(): RendererId {
  let id = sessionStorage.getItem('cosmosRendererId');

  if (!id) {
    id = uuid();
    sessionStorage.setItem('cosmosRendererId', id);
  }

  return id;
}