feat(deal-ticket): fix flaky tests (#4667)
This commit is contained in:
parent
2bbf1e2b81
commit
255c3752f2
@ -432,9 +432,9 @@ describe('StopOrder', () => {
|
||||
});
|
||||
|
||||
it('sets expiry time/date to now if expiry is changed to checked', async () => {
|
||||
const now = Math.round(Date.now() / 1000) * 1000;
|
||||
const now = 24 * 60 * 60 * 1000;
|
||||
render(generateJsx());
|
||||
jest.spyOn(global.Date, 'now').mockImplementationOnce(() => now);
|
||||
jest.spyOn(global.Date, 'now').mockImplementation(() => now);
|
||||
await userEvent.click(screen.getByTestId(expire));
|
||||
|
||||
// expiry time/date was empty it should be set to now
|
||||
|
@ -590,9 +590,9 @@ describe('DealTicket', () => {
|
||||
|
||||
it('sets expiry time/date to now if expiry is changed to checked', async () => {
|
||||
const datePicker = 'date-picker-field';
|
||||
const now = Math.round(Date.now() / 1000) * 1000;
|
||||
const now = 24 * 60 * 60 * 1000;
|
||||
render(generateJsx());
|
||||
jest.spyOn(global.Date, 'now').mockImplementationOnce(() => now);
|
||||
jest.spyOn(global.Date, 'now').mockImplementation(() => now);
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('order-tif'),
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GTT
|
||||
|
@ -496,11 +496,12 @@ export const DealTicket = ({
|
||||
onSelect={(value) => {
|
||||
// If GTT is selected and no expiresAt time is set, or its
|
||||
// behind current time then reset the value to current time
|
||||
const now = Date.now();
|
||||
if (
|
||||
value === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT &&
|
||||
(!expiresAt || new Date(expiresAt).getTime() < Date.now())
|
||||
(!expiresAt || new Date(expiresAt).getTime() < now)
|
||||
) {
|
||||
setValue('expiresAt', formatForInput(new Date()), {
|
||||
setValue('expiresAt', formatForInput(new Date(now)), {
|
||||
shouldValidate: true,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user