Commit eaa10656 by Ari Rizzitano

test some utils

parent 25ab5286
......@@ -3,7 +3,7 @@
import React from 'react';
import { mount } from 'enzyme';
import asInput from './index';
import asInput, { getDisplayName } from './index';
function testComponent(props) {
return (
......@@ -23,6 +23,14 @@ const baseProps = {
description: 'i am a test component',
};
describe('getDisplayName', () => {
it('returns the proper display name', () => {
expect(getDisplayName({ displayName: 'foo' })).toEqual('foo');
expect(getDisplayName({ name: 'bar' })).toEqual('bar');
expect(getDisplayName({})).toEqual('Component');
});
});
describe('asInput()', () => {
it('renders', () => {
const props = {
......
......@@ -5,7 +5,8 @@ import { FormGroup, FormFeedback, FormText } from 'reactstrap';
import newId from '../utils/newId';
const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'Component';
export const getDisplayName = WrappedComponent =>
WrappedComponent.displayName || WrappedComponent.name || 'Component';
export const inputProps = {
label: PropTypes.string.isRequired,
......
import newId from './newId';
describe('newId', () => {
it('increments on each call', () => {
expect(newId()).toEqual('id1');
expect(newId('foo-')).toEqual('foo-2');
expect(newId('bar-')).toEqual('bar-3');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment