Fakultas Ilmu Komputer UI

ApplyModal-test.jsx 1.33 KB
Newer Older
1
2
3
/* eslint-disable no-unused-expressions */
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
4
import ApplyModal from '../../components/ApplyModal';
5

6
describe('ApplyModal', () => {
7
  it('renders without problem', () => {
8
    const modalPendaftaran = ReactTestUtils.renderIntoDocument(
9
      <ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" />);
10
    expect(modalPendaftaran).to.exist;
11
  });
12
13
14

  it('open without problem', () => {
    const modalPendaftaran = ReactTestUtils.renderIntoDocument(
15
      <ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" />);
16
17
18

    const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
    ReactTestUtils.Simulate.click(modal);
19
  });
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  it('change without problem', () => {
    const modalPendaftaran = ReactTestUtils.renderIntoDocument(
      <ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" />);

    modalPendaftaran.handleChange({ target: { value: 'duar' } });
    expect(modalPendaftaran.state.coverLetter).to.equal('duar');
  });

  it('close without problem', () => {
    const modalPendaftaran = ReactTestUtils.renderIntoDocument(
      <ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" />);

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

37
});