Fakultas Ilmu Komputer UI

VerifyAdminModal-test.jsx 1009 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import VerifyAdminModal from '../../components/VerifyAdminModal';
import fetchMock from 'fetch-mock';
import Storage from '../../lib/Storage';

describe('VerifyAdminModal', () => {

  it('renders without problem', () => {
    const verifyModal = ReactTestUtils.renderIntoDocument(
      <VerifyAdminModal />,
    );
    expect(verifyModal).to.exist;
  });

  it('open without problem', () => {
     const verifyModal = ReactTestUtils.renderIntoDocument(
       <VerifyAdminModal id={4} />);

     const modal = ReactTestUtils.findRenderedDOMComponentWithTag(verifyModal, 'Button');
     ReactTestUtils.Simulate.click(modal);
     expect(verifyModal.state.modalOpen).to.equal(true);
   });

   it('close without problem', () => {
     const verifyModal = ReactTestUtils.renderIntoDocument(
       <VerifyAdminModal id={4} />);

     verifyModal.handleClose();
     expect(verifyModal.state.modalOpen).to.equal(false);
   });
});