How to use the react-test-renderer/shallow.createRenderer function in react-test-renderer

To help you get started, we’ve selected a few react-test-renderer 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 Armour / express-webpack-react-redux-typescript-boilerplate / frontend / src / pages / ReactPage / components / ContentLoader / __tests__ / contentLoader.spec.tsx View on Github external
it('should renders correctly', () => {
    const renderer = ShallowRenderer.createRenderer();
    const props = {
      isLoading: false,
      pastDelay: false,
      timedOut: false,
      error: null,
      retry: () => { return; },
    };
    const result = renderer.render(
      ,
    );
    expect(result).toMatchSnapshot();
    renderer.unmount();
  });
});
github coralproject / talk / src / core / client / stream / tabs / comments / queries / StreamQuery.spec.tsx View on Github external
it("renders stream container", () => {
  const data = {
    props: {
      story: {},
    } as any,
    error: null,
  };
  const renderer = createRenderer();
  renderer.render(React.createElement(() => render(data, "CREATED_AT_ASC")));
  expect(renderer.getRenderOutput()).toMatchSnapshot();
});
github coralproject / talk / src / core / client / stream / tabs / profile / components / Profile.spec.tsx View on Github external
it("renders correctly", () => {
  const props: PropTypesOf = {
    story: {},
    viewer: {},
    settings: {},
  };
  const renderer = createRenderer();
  renderer.render();
  expect(renderer.getRenderOutput()).toMatchSnapshot();
});
github coralproject / talk / src / core / client / ui / components / AppBar / AppBar.spec.tsx View on Github external
it("renders correctly", () => {
  const props: PropTypesOf = {
    children: "child",
    gutterBegin: true,
    gutterEnd: true,
    className: "custom",
  };
  const renderer = createRenderer();
  renderer.render();
  expect(renderer.getRenderOutput()).toMatchSnapshot();
});
github bentatum / better-react-spinkit / src / CubeGrid / __spec__ / index.spec.js View on Github external
import { default as React } from 'react'
import { createRenderer } from 'react-test-renderer/shallow'
import { default as expect } from 'expect'
import { default as CubeGrid } from '..'
import { default as Base } from '../../Base'

const renderer = createRenderer()

describe('CubeGrid', () => {
  let tree

  beforeEach(() => {
    renderer.render()
    tree = renderer.getRenderOutput()
  })

  it('renders a container', () => {
    expect(tree.type).toEqual(Base)
  })
})
github algolia / react-element-to-jsx-string / src / index.spec.js View on Github external
it('reactElementToJSXString(decorator(<span>)', () =&gt; {
    function myDecorator(ComposedComponent) {
      class MyDecorator extends React.Component {
        render() {
          return (
            <div>{React.createElement(ComposedComponent.type, this.props)}</div>
          );
        }
      }
      MyDecorator.displayName = `${ComposedComponent.name}-Decorated`;
      return MyDecorator;
    }

    const NestedSpan = myDecorator(<span>);
    const renderer = createRenderer();
    renderer.render();
    expect(reactElementToJSXString(renderer.getRenderOutput())).toEqual(
      `<div>
  <span>
</span></div>`
    );
  });
</span></span>
github coralproject / talk / src / core / client / stream / tabs / comments / views / permalink / queries / PermalinkViewQuery.spec.tsx View on Github external
it("renders loading", () => {
  const data = {
    props: null,
    error: null,
  };
  const renderer = createRenderer();
  renderer.render(React.createElement(() => render(data)));
  expect(renderer.getRenderOutput()).toMatchSnapshot();
});
github coralproject / talk / src / core / client / stream / tabs / Comments / PermalinkView / Timeline / Line.spec.tsx View on Github external
it("renders correctly", () =&gt; {
  const props: PropTypesOf = {
    className: "root",
    dotted: true,
  };
  const renderer = createRenderer();
  renderer.render(
github eldh / statext / packages / examples / src / todo-mvc / components / TodoTextInput.spec.js View on Github external
const setup = propOverrides =&gt; {
  const props = Object.assign(
    {
      onSave: jest.fn(),
      text: 'Use Redux',
      placeholder: 'What needs to be done?',
      editing: false,
      newTodo: false,
    },
    propOverrides
  )

  const renderer = createRenderer()

  renderer.render()

  const output = renderer.getRenderOutput()

  return {
    props: props,
    output: output,
    renderer: renderer,
  }
}
github traveloka / soya-next / examples / todomvc / components / MainSection.spec.js View on Github external
completed: true,
          id: 1
        }
      ],
      actions: {
        editTodo: jest.fn(),
        deleteTodo: jest.fn(),
        completeTodo: jest.fn(),
        completeAll: jest.fn(),
        clearCompleted: jest.fn()
      }
    },
    propOverrides
  );

  const renderer = createRenderer();
  renderer.render();
  const output = renderer.getRenderOutput();

  return {
    props,
    output,
    renderer
  };
};