UNPKG

react-hold

Version:

Hold the empty presentational components in react.js

52 lines (45 loc) 1.36 kB
import React from 'react'; import { isNull, isObject, isFunction, getDisplayName } from '../utils'; describe('utils', function () { it('isNull', function () { expect(isNull()).toBeTruthy(); expect(isNull(null)).toBeTruthy(); expect(isNull('')).toBeFalsy(); expect(isNull(0)).toBeFalsy(); }); it('isObject', function () { expect(isObject()).toBeFalsy(); expect(isObject(null)).toBeFalsy(); expect(isObject('')).toBeFalsy(); expect(isObject(0)).toBeFalsy(); expect(isObject([])).toBeFalsy(); expect(isObject({})).toBeTruthy(); expect(isObject({ foo: 'bar' })).toBeTruthy(); }); it('isFunction', function () { expect(isFunction()).toBeFalsy(); expect(isFunction({})).toBeFalsy(); expect(isFunction([])).toBeFalsy(); expect(isFunction(function () {})).toBeTruthy(); }); it('getDisplayName', function () { var Component1 = function Component1() { return React.createElement( 'div', null, 'foo' ); }; var Component2 = function Component2() { return React.createElement( 'div', null, 'bar' ); }; Component2.displayName = 'Bar'; expect(getDisplayName(Component1)).toBe('Component1'); expect(getDisplayName(Component2)).toBe('Bar'); expect(getDisplayName('div')).toBe('div'); }); });