-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add React hooks for customization (part 3) (#2542)
* Typo * Update entry * Add useActivities, useReferenceGrammarID and useSendBoxDictationStarted * Add useStyleOptions and useStyleSet * Fix errors * Use useStyleOptions and useStyleSet * Add useStyleOptions and useStyleSet * Add useStyleOptions and useStyleSet * Add useLanguage and useLocalize * Fix ESLint * Typo * Add useLocalizeDate * Use useLocalize * Fix ESLint * Cleanup * Clean up * Fix useLocalize * Revert dev build * Update setter test * Add test * Better error message on runHook * Apply PR comments * Remove useLocalizeDate test * Improve reliability
- Loading branch information
Showing
33 changed files
with
296 additions
and
205 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('getter should return language set in props', async () => { | ||
const { pageObjects } = await setupWebDriver({ | ||
props: { | ||
locale: 'zh-YUE' | ||
} | ||
}); | ||
|
||
const [groupTimestamp] = await pageObjects.runHook('useLanguage'); | ||
|
||
expect(groupTimestamp).toMatchInlineSnapshot(`"zh-YUE"`); | ||
}); | ||
|
||
test('getter should return default language if not set in props', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
const [groupTimestamp] = await pageObjects.runHook('useLanguage'); | ||
|
||
expect(groupTimestamp).toMatchInlineSnapshot(`"en-US"`); | ||
}); | ||
|
||
test('setter should be undefined', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
const [_, setLanguage] = await pageObjects.runHook('useLanguage'); | ||
|
||
expect(setLanguage).toBeUndefined(); | ||
}); |
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,18 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('calling localize should return a localized string', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
await expect(pageObjects.runHook('useLocalize', ['Chat'])).resolves.toMatchInlineSnapshot(`"Chat"`); | ||
}); | ||
|
||
test('calling localize on zh-YUE should return a localized string', async () => { | ||
const { pageObjects } = await setupWebDriver({ props: { locale: 'zh-YUE' } }); | ||
|
||
await expect(pageObjects.runHook('useLocalize', ['Chat'])).resolves.toMatchInlineSnapshot(`"傾偈"`); | ||
}); |
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
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
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
Oops, something went wrong.