Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createShallowRenderer(/* options */) {
const adapter = this;
const renderer = new ShallowRenderer();
let isDOM = false;
let cachedNode = null;
return {
render(el, context, {
providerValues = new Map(),
} = {}) {
cachedNode = el;
/* eslint consistent-return: 0 */
if (typeof el.type === 'string') {
isDOM = true;
} else if (isContextProvider(el)) {
providerValues.set(el.type, el.props.value);
const MockProvider = Object.assign(
(props) => props.children,
el.type,
);
createShallowRenderer(/* options */) {
const renderer = new ShallowRenderer();
let isDOM = false;
let cachedNode = null;
return {
render(el, context) {
cachedNode = el;
/* eslint consistent-return: 0 */
if (typeof el.type === 'string') {
isDOM = true;
} else {
isDOM = false;
return withSetStateAllowed(() => renderer.render(el, context));
}
},
unmount() {
renderer.unmount();
},
it(`should render ${i} likes if nothing is omitted`, () => {
const post = { omittedLikes: 0 };
const renderer = new ShallowRenderer();
renderer.render();
const errorBoundary = renderer.getRenderOutput().props.children;
expect(errorBoundary.props.children[1].props.children, 'to have length', i);
});
}
import React from 'react';
import Renderer from 'react-test-renderer/shallow';
import Account from 'components/Settings/Account';
import userProfile from '../__mocks__/user-profile.json';
import profileState from '../__mocks__/profile-state.json';
const rnd = new Renderer();
const settingsUI = {
TABS: {
ACCOUNT: {
MYACCOUNT: 'my account',
LINKEDACCOUNT: 'linked account',
},
},
};
it('renders account setting page correctly', () => {
rnd.render((
test('Matches shallow shapshot', () => {
const renderer = new Renderer();
const MOCK_PROPS = {
theme: {},
startDate: '2019-08-01T07:21:20.249Z',
endDate: '2019-09-01T07:21:20.249Z',
};
renderer.render();
expect(renderer.getRenderOutput()).toMatchSnapshot();
});
test('Matches shallow shapshot', () => {
const renderer = new Renderer();
renderer.render(<content>);
expect(renderer.getRenderOutput()).toMatchSnapshot();
});
</content>
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import CartOptions from '../cartOptions';
const renderer = new ShallowRenderer();
test('it renders the correct tree', () => {
const props = {
cartItem: {
item_id: 99,
name: 'cartItem name',
price: 99,
qty: 99
},
configItem: {
__typename: 'simple'
},
currencyCode: 'USD',
endEditItem: jest.fn(),
updateCart: jest.fn()
};
export default function shallowRender(element) {
const renderer = new ReactShallowRenderer()
renderer.render(element)
return renderer.getRenderOutput()
}
import _ from 'lodash';
import React from 'react';
import Rnd from 'react-test-renderer/shallow';
import TU from 'react-dom/test-utils';
const rnd = new Rnd();
const mockChallengeActions = {
challenge: {
getDetailsInit: jest.fn(),
getDetailsDone: jest.fn(),
getSubmissionsInit: jest.fn(),
getSubmissionsDone: jest.fn(),
},
};
jest.setMock(require.resolve('actions/challenge'), mockChallengeActions);
const mockSmpActions = {
smp: {
cancelDelete: jest.fn(),
confirmDelete: jest.fn(),
deleteSubmissionDone: jest.fn(),
const setup = (editing = false) => {
const props = {
todo: {
id: 0,
text: "Use Redux",
completed: false
},
editTodo: jest.fn(),
deleteTodo: jest.fn(),
completeTodo: jest.fn()
}
const renderer = new ShallowRenderer()
renderer.render()
let output = renderer.getRenderOutput()
if (editing) {
const label = output.props.children.props.children[1]
label.props.onDoubleClick({})
output = renderer.getRenderOutput()
}
return {
props: props,
output: output,
renderer: renderer
}