Created
November 2, 2022 17:23
-
-
Save adidahiya/507e9ea9648826f19eaae8fb7d276481 to your computer and use it in GitHub Desktop.
Jest mock for @blueprintjs/datetime2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// should live in __mocks__/@blueprintjs/datetime2.tsx | |
import type { DateInput2Props } from "@blueprintjs/datetime2"; | |
import * as React from "react"; | |
const datetime2 = jest.requireActual<typeof import("@blueprintjs/datetime2")>("@blueprintjs/datetime2"); | |
/** | |
* HACKHACK: our Enzyme tests rely on DateInput being a class component we can easily select & grab props from, | |
* which doesn't work with DateInput2 as it's now a function component. This shim allows the current tests to keep | |
* working. Enzyme is deprecated and unsupported; these tests should be migrated to react-testing-library. | |
* | |
* @see https://github.com/testing-library/react-testing-library | |
*/ | |
class DateInput2ClassShim extends React.Component<DateInput2Props> { | |
public render() { | |
return <datetime2.DateInput2 {...this.props} />; | |
} | |
} | |
module.exports = { | |
...datetime2, | |
DateInput2: DateInput2ClassShim, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment