@transferwise/components 46.131.1 → 46.131.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.131.1",
3
+ "version": "46.131.2",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -83,13 +83,6 @@ FocusOnSelectedDay.play = async () => {
83
83
  await userEvent.keyboard(' ');
84
84
  };
85
85
 
86
- export const FocusOnToday = Template.bind({});
87
- FocusOnToday.args = { ...props, value: null };
88
- FocusOnToday.play = async () => {
89
- await userEvent.tab();
90
- await userEvent.keyboard(' ');
91
- };
92
-
93
86
  export const FocusOnFirstNonDisabledDate = Template.bind({});
94
87
  FocusOnFirstNonDisabledDate.args = {
95
88
  ...props,
@@ -247,6 +247,28 @@ describe('DateLookup (events)', () => {
247
247
  const min = new Date(2018, 11, 26);
248
248
  const max = new Date(2018, 11, 28);
249
249
 
250
+ it('focuses on today when value is null', async () => {
251
+ const today = new Date();
252
+ const todayDateLabel = today.toLocaleDateString('en-GB', {
253
+ day: 'numeric',
254
+ month: 'numeric',
255
+ year: 'numeric',
256
+ });
257
+ const expectedHeaderText = today.toLocaleDateString('en-GB', {
258
+ month: 'long',
259
+ year: 'numeric',
260
+ });
261
+
262
+ render(<DateLookup value={null} onChange={jest.fn()} />);
263
+ await user.click(screen.getByRole('button'));
264
+ const todayButton = screen.getByLabelText(todayDateLabel);
265
+
266
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
267
+ expect(screen.getByText(expectedHeaderText)).toBeInTheDocument();
268
+ expect(todayButton).toHaveClass('today');
269
+ expect(todayButton).toHaveFocus();
270
+ });
271
+
250
272
  describe('when not clearable', () => {
251
273
  let handleChange: jest.Mock;
252
274