Skip to content

Commit

Permalink
Merge branch 'v6.X' into PWA-1774-video-in-product-description
Browse files Browse the repository at this point in the history
  • Loading branch information
fkloes authored Apr 10, 2019
2 parents 133c6d4 + 862d8e5 commit 7825e9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libraries/ui-shared/Form/Builder/builders/buildCountryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ export default (countryElement, optional = null) => {
} else {
countryKeys = Object.keys(iso3166);
}
const countryList = countryKeys.reduce((reducer, countryCode) => ({
...reducer,
[countryCode]: iso3166[countryCode].name,
}), {});
const countryList = countryKeys.reduce((reducer, countryCode) => {
if (!iso3166[countryCode]) {
logger.error(`Error: unknown country code [${countryCode}]`);
return reducer;
}
return ({
...reducer,
[countryCode]: iso3166[countryCode].name,
});
}, {});

// Add a "no selection" element
if (countryElement.required) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ describe('buildCountryList', () => {
};
expect(buildCountryList(countryElement, { '': '' })).toEqual(expected);
});

it('should ignore unknown countries', () => {
const expected = {
DE: 'Germany',
};
expect(buildCountryList({ countries: ['DE', 'ME'] })).toEqual(expected);
});
});

0 comments on commit 7825e9e

Please sign in to comment.