Skip to content

Commit

Permalink
fix: fix failing datepicker unit test (binary-com#13892)
Browse files Browse the repository at this point in the history
  • Loading branch information
lubega-deriv authored and jim-deriv committed Feb 29, 2024
1 parent e2201e3 commit 4df45d6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import moment from 'moment';
import { fireEvent, render, screen } from '@testing-library/react';
import { FlowTextField } from '../../FlowField';
import { FlowProvider } from '../../FlowProvider';
Expand Down Expand Up @@ -98,10 +97,13 @@ describe('DatePicker Component', () => {
const calendarButton = screen.getByTestId('wallets_datepicker_button');
fireEvent.click(calendarButton);

const testDay = moment().format('D');
const dateElements = screen.getAllByText(testDay);
const date = new Date();
const month = `0${date.getMonth() + 1}`.slice(-2);
const year = date.getFullYear();

const dateElements = screen.getAllByText(15);
fireEvent.click(dateElements[0]);
const testDate = `${moment().format('YYYY')}-${moment().format('MM')}-${moment().format('DD')}`;
const testDate = `${year}-${month}-15`;

expect(mockOnDateChange).toHaveBeenCalledWith(testDate);
});
Expand Down

0 comments on commit 4df45d6

Please sign in to comment.