Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function render(name: string, extraProps?: object) {
const { children, props }: IIsomorphicTestConfig = config[name] || {};
const finalProps = extraProps ? { ...props, ...extraProps } : props;
// Render to static HTML, just as a server would.
// We care merely that `render()` succeeds: it can be server-rendered.
// Errors will fail the test and log full stack traces to the console. Nifty!
const element = React.createElement(Components[name], finalProps, children);
return Enzyme.render(element);
}
test('file list should render a tr(s) even if directories without isEditing and size property given', t => {
const files = [
{
path: '/foo'
},
{
path: '/bar'
},
{
path: '/baz'
}
]
const wrapper = render(
)
t.equal(wrapper.find('tr').length, files.length)
t.end()
})
it('should render only the children if mobileOnly is provided and not mobile', () => {
const tree1 = render(
<h2>This is some content that should appear in the phone emulator!</h2>
);
const tree2 = render(
<div>Line 1</div>
<div>Line 2</div>
);
expect(tree1).toMatchSnapshot();
it('Render 1 triangle in simple Triangle', () => {
const wrapper = render(
);
expect(wrapper.find('.recharts-triangle').length).to.equal(1);
});
it('Check the attributes of the hidden input', function(done) {
const element = render(
).find('input');
expect(element.attr('value')).to.equal('');
expect(element.attr('type')).to.equal('hidden');
expect(element.attr('id')).to.equal('hidden');
expect(element.attr('name')).to.equal('hidden');
done();
});
it('Renders with prefix and suffix', function(done) {
component.prefix = 'Prefix';
component.suffix = 'Suffix';
const element = render(
).find('.input-group');
expect(element.children().length).to.equal(3);
expect(element.children().eq(0).hasClass('input-group-addon')).to.equal(true);
expect(element.children().eq(0).html()).to.equal('Prefix');
expect(element.children().eq(2).hasClass('input-group-addon')).to.equal(true);
expect(element.children().eq(2).html()).to.equal('Suffix');
component.prefix = '';
component.suffix = '';
done();
});
it('should be wrapped in an anchor with an `href`', function () {
wrapper = render()
expect(wrapper[0].name).to.equal('a')
expect(wrapper.attr('href')).to.equal('/projects/foo/bar')
})
})
test('ErrorComponent displays the content for 404 not found errors', () => {
const wrapper = render();
expect(wrapper.text()).toContain(
'The video you are looking for could not be found',
);
expect(wrapper.text()).toContain(
'This video does not exist or has not been published yet',
);
});
it('Render a basic select component', function (done) {
const element = render(
<select></select>
).children().eq(0);
expect(element).to.have.length(1);
expect(element.hasClass('form-group form-field-type-select form-group-select')).to.equal(true);
expect(element.attr('id')).to.equal('form-group-select');
done();
});