Skip to content

fix test for issue #4410 #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ Object {
"reviewOpportunities": Object {
"default": undefined,
"getReviewOpportunitiesService": [Function],
"normalizeChallenges": [Function],
},
"submissions": Object {
"default": undefined,
Expand Down
19 changes: 18 additions & 1 deletion src/services/reviewOpportunities.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,25 @@
* @desc This module provides a service for retrieving Review Opportunities and
* submitting applications.
*/
import _ from 'lodash';
import { getApi } from './api';

/**
* Sync the fields of V3 and V5 for front-end to process successfully
* @param challenges - challenges to normalize
*/
export function normalizeChallenges(challenges) {
if (challenges) {
_.map(challenges, (ch) => {
const { challenge } = ch;
if (challenge.technologies && challenge.technologies.includes('Data Science')) {
challenge.track = 'DATA_SCIENCE';
}
return _.defaults(ch, { challenge });
});
}
return challenges;
}
/**
* Service class.
*/
Expand All @@ -31,7 +48,7 @@ class ReviewOpportunitiesService {
.then(res => (res.ok ? res.json() : Promise.reject(new Error(`Error Code: ${res.status}`))))
.then(res => (
res.result.status === 200
? res.result.content
? normalizeChallenges(res.result.content)
: Promise.reject(res.result.content)
));
}
Expand Down