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

import {Button, Modal} from 'src/components';
import * as AboutModal from 'src/main/components/AboutModal';

describe('src/main/components/AboutModal', () => {
  describe('AboutModal', () => {
    it('configures and renders the about modal', () => {
      // Given
      const mockOnClose = jasmine.createSpy();
      const component = shallow(
        <AboutModal.AboutModal
          build={123}
          show={true}
          version='1.0'
          onClose={mockOnClose}
        />
      );

      // Then
      const modal = component.find(Modal);
      expect(modal.exists()).toBe(true);
      expect(modal.prop('show')).toBe(true);
      expect(modal.prop('onClose')).toEqual(mockOnClose);

      const versionLine = component.find('p.text-muted');
      expect(versionLine.text()).toMatch('v1.0-123');

      const button = component.find(Button).at(0);
      expect(button.exists()).toBe(true);
      expect(button.prop('onClick')).toEqual(mockOnClose);
    });
  });
});
