mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-16 08:10:49 -05:00
Merge pull request #4139 from LLK/release/2020-06-24
[Master] Release 2020-06-24
This commit is contained in:
commit
4b1e8e85e6
5 changed files with 709 additions and 701 deletions
1381
package-lock.json
generated
1381
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -128,7 +128,7 @@
|
||||||
"redux-mock-store": "^1.2.3",
|
"redux-mock-store": "^1.2.3",
|
||||||
"redux-thunk": "2.0.1",
|
"redux-thunk": "2.0.1",
|
||||||
"sass-loader": "6.0.6",
|
"sass-loader": "6.0.6",
|
||||||
"scratch-gui": "0.1.0-prerelease.20200618175748",
|
"scratch-gui": "0.1.0-prerelease.20200622200348",
|
||||||
"scratch-l10n": "latest",
|
"scratch-l10n": "latest",
|
||||||
"selenium-webdriver": "3.6.0",
|
"selenium-webdriver": "3.6.0",
|
||||||
"slick-carousel": "1.6.0",
|
"slick-carousel": "1.6.0",
|
||||||
|
|
|
@ -456,7 +456,7 @@ class DemographicsStep extends React.Component {
|
||||||
// look up country name using user's country code selection ('us' -> 'United States')
|
// look up country name using user's country code selection ('us' -> 'United States')
|
||||||
getCountryName (values) {
|
getCountryName (values) {
|
||||||
if (values.countryCode) {
|
if (values.countryCode) {
|
||||||
const countryInfo = countryData.lookupCountryInfo(values.countryCode);
|
const countryInfo = countryData.lookupCountryByCode(values.countryCode);
|
||||||
if (countryInfo) {
|
if (countryInfo) {
|
||||||
return countryInfo.name;
|
return countryInfo.name;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ class DemographicsStep extends React.Component {
|
||||||
// look up country code from country label ('United States' -> 'us')
|
// look up country code from country label ('United States' -> 'us')
|
||||||
// if `countryName` is not found, including if it's null or undefined, then this function will return undefined.
|
// if `countryName` is not found, including if it's null or undefined, then this function will return undefined.
|
||||||
getCountryCode (countryName) {
|
getCountryCode (countryName) {
|
||||||
const country = countryData.countryInfo.find(countryItem => countryItem.name === countryName);
|
const country = countryData.lookupCountryByName(countryName);
|
||||||
return country && country.code;
|
return country && country.code;
|
||||||
}
|
}
|
||||||
handleValidSubmit (formData) {
|
handleValidSubmit (formData) {
|
||||||
|
|
|
@ -1036,10 +1036,14 @@ const countryOptions = module.exports.countryOptions = (startingCountryInfo, val
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
module.exports.lookupCountryInfo = countryCode => (
|
module.exports.lookupCountryByCode = countryCode => (
|
||||||
countryInfo.find(country => country.code === countryCode)
|
countryInfo.find(country => country.code === countryCode)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
module.exports.lookupCountryByName = countryName => (
|
||||||
|
countryInfo.find(country => country.name === countryName)
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function dupeCommonCountries():
|
* Function dupeCommonCountries():
|
||||||
* takes startingCountryInfo, and duplicates any number of its country labels
|
* takes startingCountryInfo, and duplicates any number of its country labels
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
const {
|
const {
|
||||||
countryInfo,
|
countryInfo,
|
||||||
countryOptions,
|
countryOptions,
|
||||||
lookupCountryInfo,
|
lookupCountryByCode,
|
||||||
|
lookupCountryByName,
|
||||||
dupeCommonCountries,
|
dupeCommonCountries,
|
||||||
registrationCountryCodeOptions,
|
registrationCountryCodeOptions,
|
||||||
registrationCountryNameOptions,
|
registrationCountryNameOptions,
|
||||||
|
@ -45,9 +46,17 @@ describe('unit test lib/country-data.js', () => {
|
||||||
expect(szInfo.label).toEqual('Eswatini');
|
expect(szInfo.label).toEqual('Eswatini');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('lookupCountryInfo() will find country info', () => {
|
test('lookupCountryByCode() will find country info', () => {
|
||||||
expect(typeof lookupCountryInfo).toBe('function');
|
expect(typeof lookupCountryByCode).toBe('function');
|
||||||
const eswatiniInfo = lookupCountryInfo('sz');
|
const eswatiniInfo = lookupCountryByCode('sz');
|
||||||
|
expect(eswatiniInfo.name).toEqual('Swaziland');
|
||||||
|
expect(eswatiniInfo.display).toEqual('Eswatini');
|
||||||
|
expect(eswatiniInfo.code).toEqual('sz');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('lookupCountryByName() will find country info', () => {
|
||||||
|
expect(typeof lookupCountryByName).toBe('function');
|
||||||
|
const eswatiniInfo = lookupCountryByName('Swaziland');
|
||||||
expect(eswatiniInfo.name).toEqual('Swaziland');
|
expect(eswatiniInfo.name).toEqual('Swaziland');
|
||||||
expect(eswatiniInfo.display).toEqual('Eswatini');
|
expect(eswatiniInfo.display).toEqual('Eswatini');
|
||||||
expect(eswatiniInfo.code).toEqual('sz');
|
expect(eswatiniInfo.code).toEqual('sz');
|
||||||
|
|
Loading…
Reference in a new issue