Skip to content

Commit 34aac46

Browse files
authored
Merge pull request #174 from simranb86/issue_4410
fix test for issue #4410
2 parents 78107b9 + 6ffac21 commit 34aac46

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

__tests__/__snapshots__/index.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ Object {
342342
"reviewOpportunities": Object {
343343
"default": undefined,
344344
"getReviewOpportunitiesService": [Function],
345+
"normalizeChallenges": [Function],
345346
},
346347
"submissions": Object {
347348
"default": undefined,

src/services/reviewOpportunities.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,25 @@
33
* @desc This module provides a service for retrieving Review Opportunities and
44
* submitting applications.
55
*/
6+
import _ from 'lodash';
67
import { getApi } from './api';
78

9+
/**
10+
* Sync the fields of V3 and V5 for front-end to process successfully
11+
* @param challenges - challenges to normalize
12+
*/
13+
export function normalizeChallenges(challenges) {
14+
if (challenges) {
15+
_.map(challenges, (ch) => {
16+
const { challenge } = ch;
17+
if (challenge.technologies && challenge.technologies.includes('Data Science')) {
18+
challenge.track = 'DATA_SCIENCE';
19+
}
20+
return _.defaults(ch, { challenge });
21+
});
22+
}
23+
return challenges;
24+
}
825
/**
926
* Service class.
1027
*/
@@ -31,7 +48,7 @@ class ReviewOpportunitiesService {
3148
.then(res => (res.ok ? res.json() : Promise.reject(new Error(`Error Code: ${res.status}`))))
3249
.then(res => (
3350
res.result.status === 200
34-
? res.result.content
51+
? normalizeChallenges(res.result.content)
3552
: Promise.reject(res.result.content)
3653
));
3754
}

0 commit comments

Comments
 (0)