diff --git a/playbook/app/pb_kits/playbook/pb_date_picker/date_picker.test.js b/playbook/app/pb_kits/playbook/pb_date_picker/date_picker.test.js index 2c32f6423e..423ba7e26f 100644 --- a/playbook/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +++ b/playbook/app/pb_kits/playbook/pb_date_picker/date_picker.test.js @@ -5,16 +5,15 @@ import { fireEvent, render, screen, waitFor, within } from '../utilities/test-ut import DatePicker from './_date_picker' import { getTimezoneText } from './plugins/timeSelect' + + +jest.setSystemTime(new Date('01/01/2020')); const DEFAULT_DATE = new Date() -DEFAULT_DATE.setFullYear(2022) -DEFAULT_DATE.setMonth(1) -DEFAULT_DATE.setDate(1) -DEFAULT_DATE.setHours(12) -DEFAULT_DATE.setMinutes(0) + describe('DatePicker Kit', () => { beforeEach(() => { - jest.spyOn(console, 'error').mockImplementation(() => {}); + jest.spyOn(console, 'error').mockImplementation(() => { }); }); test('renders DatePicker input field', () => { @@ -44,10 +43,12 @@ describe('DatePicker Kit', () => { const kit = screen.getByTestId(testId) + const input = within(kit).getByPlaceholderText('Select Date') expect(input).toBeInTheDocument() + await waitFor(() => { - expect(input).toHaveValue('02/01/2022') + expect(input).toHaveValue('01/01/2020') }) }) @@ -143,7 +144,7 @@ describe('DatePicker Kit', () => { }), ) await waitFor(() => { - expect(input).toHaveValue('02/01/2022 at 12:00 AM') + expect(input).toHaveValue('01/01/2020 at 12:00 AM') }) fireEvent( @@ -154,7 +155,7 @@ describe('DatePicker Kit', () => { }), ) await waitFor(() => { - expect(input).toHaveValue('02/01/2022 at 12:00 PM') + expect(input).toHaveValue('01/01/2020 at 12:00 PM') }) }) }) diff --git a/playbook/jest.config.js b/playbook/jest.config.js index da134d9988..93733cc5b5 100644 --- a/playbook/jest.config.js +++ b/playbook/jest.config.js @@ -182,7 +182,7 @@ module.exports = { // testURL: "http://localhost", // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" - // timers: "real", + timers: "modern", // A map from regular expressions to paths to transformers // transform: undefined,