Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fasilkom UI Open Source Software
Kape
Commits
c185ac43
Commit
c185ac43
authored
Apr 15, 2017
by
M. Reza Qorib
Browse files
[#140652771] #18 Refactor test codes
parent
b9ac3cf0
Changes
6
Hide whitespace changes
Inline
Side-by-side
assets/js/__test__/components/ApplyModal-test.jsx
View file @
c185ac43
...
...
@@ -4,11 +4,11 @@ import ReactTestUtils from 'react-addons-test-utils';
import
ApplyModal
from
'
../../components/ApplyModal
'
;
describe
(
'
ApplyModal
'
,
()
=>
{
it
(
'
renders without problem
'
,
()
=>
{
it
(
'
renders without problem
'
,
()
=>
{
const
modalPendaftaran
=
ReactTestUtils
.
renderIntoDocument
(
<
ApplyModal
id
=
{
4
}
data
=
{
{
key
:
'
value
'
}
}
buttonTitle
=
"submit"
/>);
<
ApplyModal
id
=
{
4
}
data
=
{
{
key
:
'
value
'
}
}
buttonTitle
=
"submit"
/>);
expect
(
modalPendaftaran
).
to
.
exist
;
});
});
it
(
'
open without problem
'
,
()
=>
{
const
modalPendaftaran
=
ReactTestUtils
.
renderIntoDocument
(
...
...
assets/js/__test__/components/CompanyVacancy-test.js
View file @
c185ac43
/**
* Created by baisa on 09/04/2017.
*/
import
React
from
'
react
'
;
import
ReactTestUtils
from
'
react-addons-test-utils
'
;
import
CompanyVacancy
from
'
../../components/CompanyVacancy
'
;
describe
(
'
ApplyModal
'
,
()
=>
{
it
(
'
renders without problem
'
,
()
=>
{
describe
(
'
CompanyVacancy
'
,
()
=>
{
const
response
=
{
close_time
:
'
2019-03-28T05:55:42Z
'
,
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
logo
:
null
,
name
:
'
tutup lapak
'
,
},
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
id
:
3
,
name
:
'
Software Engineer
'
,
open_time
:
'
2017-03-28T05:55:38Z
'
,
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
};
const
response2
=
{
close_time
:
'
2019-03-28T05:55:42Z
'
,
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
logo
:
'
pictures
'
,
name
:
'
tutup lapak
'
,
},
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
id
:
3
,
name
:
'
Software Engineer
'
,
open_time
:
'
2017-03-28T05:55:38Z
'
,
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
};
it
(
'
renders with logo without problem
'
,
()
=>
{
const
companyVacancy
=
ReactTestUtils
.
renderIntoDocument
(
<
CompanyVacancy
data
=
{
response2
}
/>
)
;
expect
(
companyVacancy
).
to
.
exist
;
});
it
(
'
renders without logo without problem
'
,
()
=>
{
const
companyVacancy
=
ReactTestUtils
.
renderIntoDocument
(
<
CompanyVacancy
header
=
"
header
"
/>
);
<
CompanyVacancy
data
=
{
response
}
/>
)
;
expect
(
companyVacancy
).
to
.
exist
;
});
}
});
});
assets/js/__test__/components/Vacancy-test.jsx
View file @
c185ac43
...
...
@@ -8,11 +8,11 @@ describe('Vacancy', () => {
const
fetchMock
=
require
(
'
fetch-mock
'
);
const
response
=
{
close_time
:
'
2019-03-28T05:55:42Z
'
,
company
:
{
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
logo
:
null
,
name
:
'
tutup lapak
'
,
id
:
1
,
logo
:
null
,
name
:
'
tutup lapak
'
,
},
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
...
...
assets/js/__test__/components/VacancyList-test.jsx
View file @
c185ac43
...
...
@@ -22,19 +22,26 @@ describe('VacancyList', () => {
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
}];
// const response2 = { hello: 'not-world' };
it
(
'
renders without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
vacancyList
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyList
student
Id
=
{
1
}
url
=
"test"
/>);
<
VacancyList
user
Id
=
{
1
}
url
=
"test"
/>);
expect
(
vacancyList
).
to
.
exist
;
});
it
(
'
renders without problem for company
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
vacancyList
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyList
type
=
'company'
userId
=
{
1
}
url
=
"test"
/>);
vacancyList
.
state
.
vacancies
=
response
;
expect
(
vacancyList
.
generateVacancies
()).
to
.
exist
;
});
it
(
'
update bookmarks without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
vacancyList
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyList
student
Id
=
{
1
}
url
=
"test"
/>);
<
VacancyList
user
Id
=
{
1
}
url
=
"test"
/>);
vacancyList
.
updateBookmarkList
();
expect
(
JSON
.
stringify
(
vacancyList
.
state
.
bookmarkList
)).
to
.
be
.
defined
;
});
...
...
@@ -42,19 +49,27 @@ describe('VacancyList', () => {
it
(
'
renders marked bookmarked vacancies without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
vacancyList
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyList
student
Id
=
{
1
}
url
=
"test"
/>);
<
VacancyList
user
Id
=
{
1
}
url
=
"test"
/>);
vacancyList
.
state
.
vacancies
=
response
;
vacancyList
.
state
.
bookmarkList
=
[{
id
:
5
},
{
id
:
3
}];
vacancyList
.
state
.
bookmarkList
=
[{
id
:
5
},
{
id
:
3
},
{
id
:
1
}];
expect
(
vacancyList
.
generateVacancies
()).
to
.
exist
;
});
it
(
'
renders not marked vacancies without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
vacancyList
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyList
userId
=
{
1
}
url
=
"test"
/>);
vacancyList
.
state
.
vacancies
=
response
;
vacancyList
.
state
.
bookmarkList
=
[{
id
:
6
},
{
id
:
4
},
{
id
:
2
}];
expect
(
vacancyList
.
generateVacancies
()).
to
.
exist
;
});
it
(
'
success calling API
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
vacancyList
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyList
student
Id
=
{
1
}
url
=
"test"
/>);
<
VacancyList
user
Id
=
{
1
}
url
=
"test"
/>);
vacancyList
.
state
.
vacancies
=
response
;
expect
(
JSON
.
stringify
(
vacancyList
.
state
.
vacancies
)).
to
.
equal
(
JSON
.
stringify
(
response
));
expect
(
vacancyList
.
generateVacancies
()).
to
.
exist
;
});
});
assets/js/components/VacancyList.jsx
View file @
c185ac43
...
...
@@ -24,10 +24,10 @@ export default class VacancyList extends React.Component {
if
(
this
.
props
.
type
===
'
student
'
)
{
this
.
updateBookmarkList
();
}
this
.
state
=
{
vacancies
:
[],
bookmarkList
:
[]
};
Server
.
get
(
this
.
props
.
url
,
false
).
then
((
data
)
=>
{
this
.
setState
({
vacancies
:
data
});
});
this
.
state
=
{
vacancies
:
[],
bookmarkList
:
[]
};
this
.
updateBookmarkList
=
this
.
updateBookmarkList
.
bind
(
this
);
this
.
generateVacancies
=
this
.
generateVacancies
.
bind
(
this
);
this
.
checkBookmark
=
this
.
checkBookmark
.
bind
(
this
);
...
...
debug.log
0 → 100644
View file @
c185ac43
[0415/162748.577:ERROR:prune_crash_reports.cc(35)] PruneCrashReportDatabase: Failed to get pending reports
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment