Skip to content

Commit

Permalink
Merge branch 'master' into renovate/jest-fail-on-console-2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperfurniss committed Aug 29, 2022
2 parents 79bea46 + 2f59847 commit 90de6d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions playbook/app/pb_kits/playbook/pb_date_picker/date_picker.test.js
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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')
})
})

Expand Down Expand Up @@ -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(
Expand All @@ -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')
})
})
})
2 changes: 1 addition & 1 deletion playbook/jest.config.js
Expand Up @@ -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,
Expand Down

0 comments on commit 90de6d0

Please sign in to comment.