microsoft / microsoft/BotFramework-WebChat
Add test for `useLocalizeDate`
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 1.6k
- Avg merge
- 22h 58m
- Merged PRs (30d)
- 2
Description
Feature Request
Description
While we are adding the useLocalizeDate hook, we found out we didn't test getLocaleString function at all.
But when we try to add the test, we are hitting timezone problem. Timezone of the CI box and local box could be different.
To mitigate the problem, we need to add some code in production codebase to allow the user to select timezone. For example, the options passed to Intl.DateTimeFormat should have { timeZone: 'utc' }.
Instead of doing it in the PR, we are adding a new issue and address it later.
Actual code
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 localizeDate should return a localized date time string', async () => {
const { pageObjects } = await setupWebDriver();
await expect(
pageObjects.runHook('useLocalizeDate', [new Date(2000, 0, 2, 12, 34, 56)])
).resolves.toMatchInlineSnapshot(`"January 02, 20:34"`);
});
[Enhancement]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the useLocalizeDate hook and its getLocaleString function, then inspect the Jest test using setupWebDriver and the inline snapshot. Make the date formatting and test independent of the machine timezone while allowing the intended timezone option, and verify the localized output with the test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100