-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Italian Support for Confirm/Choice Prompts (#1500)
* - added Italian support - Added PromptCultureModels tests * remove carat from recognizers Co-authored-by: johnataylor <[email protected]>
- Loading branch information
1 parent
603bca5
commit bcfad6a
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
libraries/botbuilder-dialogs/tests/promptCultureModels.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const assert = require('assert'); | ||
const { PromptCultureModels } = require('../lib') | ||
|
||
describe('Prompt Culture Models Tests', function() { | ||
this.timeout(5000); | ||
|
||
it('should correctly map to nearest language', function() { | ||
const locales = [ | ||
'es-es', | ||
'nl-nl', | ||
'en-us', | ||
'fr-fr', | ||
'de-de', | ||
'ja-jp', | ||
'it-it', | ||
'pt-br', | ||
'zh-cn' | ||
]; | ||
// es-ES | ||
const capEnding = (locale) => { | ||
return `${ locale.split('-')[0] }-${ locale.split('-')[1].toUpperCase() }`; | ||
}; | ||
// es-Es | ||
const titleEnding = (locale) => { | ||
locale[3] = locale.charAt(3).toUpperCase(); | ||
return locale; | ||
}; | ||
// ES | ||
const capTwoLetter = (locale) => { | ||
return locale.split('-')[0].toUpperCase(); | ||
}; | ||
// es | ||
const lowerTwoLetter = (locale) => { | ||
return locale.split('-')[0].toLowerCase(); | ||
}; | ||
|
||
// This creates an object of the correct locale along with its test locales | ||
const localeTests = locales.reduce((obj, locale) => { | ||
obj[locale] = [ | ||
locale, | ||
capEnding(locale), | ||
titleEnding(locale), | ||
capTwoLetter(locale), | ||
lowerTwoLetter(locale) | ||
]; | ||
return obj; | ||
}, {}); | ||
|
||
Object.keys(localeTests).map((validLocale) => { | ||
localeTests[validLocale].map((testLocale) => { | ||
assert.strictEqual(PromptCultureModels.mapToNearestLanguage(testLocale), validLocale); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should return all supported cultures', function() { | ||
const expected = [ | ||
PromptCultureModels.Chinese, | ||
PromptCultureModels.Dutch, | ||
PromptCultureModels.English, | ||
PromptCultureModels.French, | ||
PromptCultureModels.German, | ||
PromptCultureModels.Italian, | ||
PromptCultureModels.Japanese, | ||
PromptCultureModels.Portuguese, | ||
PromptCultureModels.Spanish | ||
]; | ||
|
||
const supportedCultures = PromptCultureModels.getSupportedCultures(); | ||
|
||
assert.deepEqual(supportedCultures, expected); | ||
}); | ||
}); |