-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathgetFunctionTypeName.spec.js
More file actions
41 lines (32 loc) · 1.03 KB
/
getFunctionTypeName.spec.js
File metadata and controls
41 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @jest-environment jsdom
*/
/* @flow */
import React from 'react';
import getFunctionTypeName from './getFunctionTypeName';
function NamedStatelessComponent(props: { children: React.Children }) {
const { children } = props;
return <div>{children}</div>;
}
const _default = function(props: { children: React.Children }) {
const { children } = props;
return <div>{children}</div>;
};
const NamelessComponent = function(props: { children: React.Children }) {
const { children } = props;
return <div>{children}</div>;
};
delete NamelessComponent.name;
describe('getFunctionTypeName(Component)', () => {
it('getFunctionTypeName(NamedStatelessComponent)', () => {
expect(getFunctionTypeName(NamedStatelessComponent)).toEqual(
'NamedStatelessComponent'
);
});
it('getFunctionTypeName(_default)', () => {
expect(getFunctionTypeName(_default)).toEqual('Component');
});
it('getFunctionTypeName(NamelessComponent)', () => {
expect(getFunctionTypeName(NamelessComponent)).toEqual('Component');
});
});