|
1 | 1 | import { getContextValue, renderWithContext } from '@ima/testing-library';
|
2 |
| -import { PureComponent, createRef } from 'react'; |
| 2 | +import { PureComponent, createRef, memo, forwardRef } from 'react'; |
3 | 3 |
|
4 | 4 | import forwardedSelect, {
|
5 | 5 | createStateSelector,
|
@@ -159,6 +159,37 @@ describe('plugin-select:', () => {
|
159 | 159 | expect(container.firstChild).toMatchSnapshot();
|
160 | 160 | });
|
161 | 161 |
|
| 162 | + it('should set displayName for class component', async () => { |
| 163 | + const EnhancedComponent = select(...selectorMethods)(Component); |
| 164 | + |
| 165 | + expect(EnhancedComponent.displayName).toBe('withContext(Component)'); |
| 166 | + }); |
| 167 | + |
| 168 | + it('should set displayName for functional component', async () => { |
| 169 | + const FunctionalComponent = () => { |
| 170 | + return <div />; |
| 171 | + }; |
| 172 | + const EnhancedComponent = select(...selectorMethods)(FunctionalComponent); |
| 173 | + |
| 174 | + expect(EnhancedComponent.displayName).toBe( |
| 175 | + 'withContext(FunctionalComponent)' |
| 176 | + ); |
| 177 | + }); |
| 178 | + |
| 179 | + it('should set displayName for memoized component', async () => { |
| 180 | + const MemoComponent = memo(Component); |
| 181 | + const EnhancedComponent = select(...selectorMethods)(MemoComponent); |
| 182 | + |
| 183 | + expect(EnhancedComponent.displayName).toBe('withContext(Component)'); |
| 184 | + }); |
| 185 | + |
| 186 | + it('should set displayName for forwarded component', async () => { |
| 187 | + const ForwardedComponent = forwardRef(Component); |
| 188 | + const EnhancedComponent = select(...selectorMethods)(ForwardedComponent); |
| 189 | + |
| 190 | + expect(EnhancedComponent.displayName).toBe('withContext(Component)'); |
| 191 | + }); |
| 192 | + |
162 | 193 | it('should render component with extraProps modifies by ownProps', async () => {
|
163 | 194 | let EnhancedComponent = select(
|
164 | 195 | ...selectorMethods,
|
|
0 commit comments