Commit eaa10656 by Ari Rizzitano

test some utils

parent 25ab5286
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import asInput from './index'; import asInput, { getDisplayName } from './index';
function testComponent(props) { function testComponent(props) {
return ( return (
...@@ -23,6 +23,14 @@ const baseProps = { ...@@ -23,6 +23,14 @@ const baseProps = {
description: 'i am a test component', 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()', () => { describe('asInput()', () => {
it('renders', () => { it('renders', () => {
const props = { const props = {
......
...@@ -5,7 +5,8 @@ import { FormGroup, FormFeedback, FormText } from 'reactstrap'; ...@@ -5,7 +5,8 @@ import { FormGroup, FormFeedback, FormText } from 'reactstrap';
import newId from '../utils/newId'; 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 = { export const inputProps = {
label: PropTypes.string.isRequired, 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