Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest/__mocks__/FakeComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.

13 changes: 13 additions & 0 deletions jest/__tests__/mockComponent-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mockComponent = require('../mockComponent');
const FakeComponent = require('FakeComponent')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.

const TextInput = require('TextInput')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.


it('defaults to a displayName of "Component" when the mocked component does not have one', () => {
expect(FakeComponent.displayName).toBeUndefined();
expect(mockComponent('FakeComponent').displayName).toBe('Component');
});

it('forwards the mocked component\'s displayName when available', () => {
expect(TextInput.displayName).toBe('TextInput');
expect(mockComponent('TextInput').displayName).toBe('TextInput');
});
2 changes: 1 addition & 1 deletion jest/mockComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = (moduleName, instanceMethods) => {
typeof RealComponent === 'function' ? RealComponent : React.Component;

const Component = class extends SuperClass {
static displayName = 'Component';
static displayName = SuperClass.displayName || 'Component';

render() {
const name =
Expand Down