import { shallow } from 'enzyme';
import React from 'react';

import LoaderOverlay from './LoaderOverlay';

describe('LoaderOverlay component', () => {
  let wrapper;

  beforeEach(() => {
    wrapper = shallow(<LoaderOverlay />);
  });

  it('renders', () => {
    expect(wrapper).toExist();
  });

  it('renders an SUI Dimmer', () => {
    const dimmer = wrapper.find('Dimmer');
    expect(dimmer).toExist();
    expect(dimmer).toHaveProp('active', true);
  });

  it('renders an SUI Loader within the Dimmer', () => {
    expect(wrapper.find('Dimmer').find('Loader')).toExist();
  });

  it('marks the dimmer as inverted', () => {
    expect(wrapper.find('Dimmer')).toHaveProp('inverted', true);
  });

  it('allows the dimmer to be "un-inverted"', () => {
    wrapper.setProps({ inverted: true });
    expect(wrapper.find('Dimmer')).toHaveProp('inverted', false);
  });

  it('sets the loader size to "massive"', () => {
    expect(wrapper.find('Loader')).toHaveProp('size', 'massive');
  });

  it('allows the loader size to be customised', () => {
    wrapper.setProps({ size: 'small' });
    expect(wrapper.find('Loader')).toHaveProp('size', 'small');
  });
});
