huridocs/uwazi

View on GitHub
app/react/Layout/specs/Modal.spec.js

Summary

Maintainability
A
0 mins
Test Coverage
import React from 'react';
import { shallow } from 'enzyme';

import Modal from 'app/Layout/Modal';
import ReactModal from 'react-modal';

describe('Modal', () => {
  let component;

  const render = (props = {}) => {
    component = shallow(
      <Modal {...props}>
        <div />
      </Modal>
    );
  };

  it('should pass isOpen props', () => {
    render({ isOpen: false });
    expect(component.find(ReactModal).props().isOpen).toBe(false);
    render({ isOpen: true });
    expect(component.find(ReactModal).props().isOpen).toBe(true);
  });

  it('should append type passed to modal class and render default success if nothing passed', () => {
    render({ type: 'modalType' });
    expect(component.find(ReactModal).hasClass('modal-modalType')).toBe(true);
    render();
    expect(component.find(ReactModal).hasClass('modal-success')).toBe(true);
  });
});