Fakultas Ilmu Komputer UI

VacancyPage-test.jsx 4.43 KB
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
33
34
35
36
37
38
/* eslint-disable no-unused-expressions */
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import VacancyPage from '../VacancyPage';
import Storage from '../lib/Storage';
// import Server from '../../lib/Server';

describe('VacancyList', () => {
  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: {
        url: 'http://localhost:8000/api/users/9/',
        username: 'muhammad.reza42',
        email: 'muhammad.reza42@ui.ac.id',
        is_staff: false,
      },
      name: 'Muhammad R.',
      created: '2017-03-28T13:33:46.147241Z',
      updated: '2017-03-28T13:33:46.148248Z',
      npm: 1406543593,
      resume: null,
      phone_number: null,
      bookmarked_vacancies: [
        3,
      ],
      applied_vacancies: [
        3,
        1,
      ],
    },
  };
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  const companySession = {
    url: 'http://localhost:8001/api/users/8/',
    username: 'Tutuplapak',
    email: '',
    is_staff: false,
    company: {
      id: 3,
      user: {
        url: 'http://localhost:8001/api/users/8/',
        username: 'Tutuplapak',
        email: '',
        is_staff: false,
      },
      name: 'Tutuplapak',
      created: '2017-03-28T07:30:10.535000Z',
      updated: '2017-03-28T07:30:10.535000Z',
      description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla aliquet semper neque a fermentum. Duis ac tellus vitae augue iaculis ultrices. Curabitur commodo et neque nec feugiat. Morbi ac diam vel nunc commodo cursus. Phasellus nulla sapien, hendrerit vitae bibendum at, sollicitudin eu ante. Maecenas maximus, ante eu sollicitudin convallis, mauris nunc posuere risus, eu porttitor diam lacus vitae enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse at lectus a elit sollicitudin tempor. Nullam condimentum, justo nec tincidunt maximus, neque mi vulputate leo, sit amet lacinia massa ex eget sem. Duis ac erat facilisis, fringilla mauris in, consequat neque. In et neque consequat, vehicula magna at, efficitur ante. Mauris ac lacinia nibh.\r\n\r\nProin sagittis, lectus quis maximus varius, libero justo sollicitudin augue, non lacinia risus orci a enim. Curabitur iaculis enim quis ullamcorper commodo. Vivamus id nisi rhoncus, dignissim tellus quis, interdum est. Fusce sollicitudin eu libero ac feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper posuere ex, sed accumsan libero iaculis faucibus. Fusce laoreet ac ligula ut consectetur. Donec tortor mauris, rutrum at sodales et, viverra in dolor. Sed bibendum elit et maximus volutpat. Phasellus justo ipsum, laoreet sit amet faucibus eu, ultricies suscipit mauris. Nullam aliquam libero eu ante ultrices mattis. Donec non justo hendrerit neque volutpat placerat. Ut euismod est nec sem mollis, sit amet porttitor massa rhoncus. Aenean id erat sit amet nunc ultrices scelerisque non in ipsum. Curabitur sollicitudin nulla id mi accumsan venenatis.',
      verified: true,
      logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png',
      address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat',
    },
    supervisor: null,
    student: null,
  };
64
65
66
67
68
69
70
71
72
73
74

  const errorSession = {
    url: 'http://localhost:8001/api/users/8/',
    username: 'Tutuplapak',
    email: '',
    is_staff: false,
    company: null,
    supervisor: null,
    student: null,
  };

75
76
77
78
79
80
81
82
83
84
85
86
87
  it('renders for companies without problem', () => {
    Storage.set('user-data', companySession);
    const vacancyPage = ReactTestUtils.renderIntoDocument(
      <VacancyPage studentId={1} url="test" />);
    expect(vacancyPage).to.exist;
    expect(vacancyPage.state.role).to.equal('company');
  });

  it('renders for students without problem', () => {
    Storage.set('user-data', studentSession);
    const vacancyPage = ReactTestUtils.renderIntoDocument(
      <VacancyPage studentId={1} url="test" />);
    expect(vacancyPage).to.exist;
88
89
90
91
92
93
94
95
96
    expect(vacancyPage.state.role).to.equal('student');
  });

  it('renders without problem for error case', () => {
    Storage.set('user-data', errorSession);
    const vacancyPage = ReactTestUtils.renderIntoDocument(
      <VacancyPage studentId={1} url="test" />);
    expect(vacancyPage).to.exist;
    expect(vacancyPage.state.role).to.equal('error');
97
98
99
  });
});