import { getDisplayName } from './components';

describe('getDisplayName', () => {
  it('reads the displayName from a component', () => {
    const displayName = 'test display name';
    expect(getDisplayName({ displayName })).toBe(displayName);
  });

  it('reads the name from a component', () => {
    const name = 'test display name';
    expect(getDisplayName({ name })).toBe(name);
  });

  it('prefers the displayName to the name', () => {
    const displayName = 'test display name';
    const name = 'test display name';
    expect(getDisplayName({ displayName, name })).toBe(displayName);
  });

  it('copes when neither name is available', () => {
    expect(getDisplayName({ })).toBe('Component');
  });
});
