Fakultas Ilmu Komputer UI

NotificationPage-test.jsx 2 KB
Newer Older
1
import React from 'react';
Syahrul Findi's avatar
Syahrul Findi committed
2
import ReactTestUtils from 'react-dom/test-utils';
3
import NotificationPage from '../NotificationPage';
4
5
6
import Notification from '../components/Notification';
import TopMenu from '../components/TopMenu';
import { studentUser } from '../object/Response';
7
8

describe('NotificationPage', () => {
9
10
11
12
13
14
15
16
17
18
  const studentSession = {
    url: 'http://localhost:8000/api/users/9/',
    username: 'muhammad.reza42',
    email: 'muhammad.reza42@ui.ac.id',
    is_staff: false,
    company: null,
    supervisor: null,
    student: {
      id: 3,
      user: {
19
20
21
22
        url: 'http://localhost:8000/api/users/9/',
        username: 'muhammad.reza42',
        email: 'muhammad.reza42@ui.ac.id',
        is_staff: false,
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
      },
      name: 'Muhammad R.',
      created: '2017-03-28T13:33:46.147241Z',
      updated: '2017-03-28T13:33:46.148248Z',
      npm: 1406543593,
      resume: null,
      phone_number: null,
      birth_place: null,
      birth_date: null,
      major: null,
      batch: null,
      show_resume: false,
      bookmarked_vacancies: [
        3,
        2,
      ],
      applied_vacancies: [
        3,
        1,
      ],
    },
  };
45

46
47
48
49
50
  it('renders for notification page without problem', () => {
    const notification = ReactTestUtils.renderIntoDocument(
      <NotificationPage user={{ data: studentSession }}/>);
    expect(notification).to.exist;
  });
51

52
53
54
55
56
57
58
59
60
61
62
63
64
  it('sets top menu active item according to page', () => {
    ReactTestUtils.renderIntoDocument(
      <NotificationPage
        user={{ data: studentSession }}
      />,
    );
    const topmenu = ReactTestUtils.renderIntoDocument(
      <TopMenu user={studentUser}>
        <div> test </div>
      </TopMenu>,
    );
    expect(topmenu.state.activeItem).to.equal('Notifikasi');
  });
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
65
66
67
68
69
70
71
72
73
74
75

  it('test click dismiss notif',()=>{
    const notifpage = ReactTestUtils.renderIntoDocument(
      <NotificationPage
        user={{ data: studentSession }}
      />,
    );

    notifpage.onClickDismiss(0);
    expect(notifpage.state.list.length).to.equal(2);
  });
76
});