mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-09-10 18:26:15 +02:00
refactor(starter): upgrade to new version of gatsby
This commit is contained in:
29
src/components/Post/Comments/Comments.test.tsx
Normal file
29
src/components/Post/Comments/Comments.test.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import React from "react";
|
||||
import renderer from "react-test-renderer";
|
||||
|
||||
import { StaticQuery, useStaticQuery } from "gatsby";
|
||||
|
||||
import { Comments } from "@/components/Post/Comments";
|
||||
import * as mocks from "@/mocks";
|
||||
|
||||
const mockedStaticQuery = StaticQuery as jest.Mock;
|
||||
const mockedUseStaticQuery = useStaticQuery as jest.Mock;
|
||||
|
||||
describe("Comments", () => {
|
||||
beforeEach(() => {
|
||||
mockedStaticQuery.mockImplementationOnce(({ render }) =>
|
||||
render(mocks.siteMetadata),
|
||||
);
|
||||
mockedUseStaticQuery.mockReturnValue(mocks.siteMetadata);
|
||||
});
|
||||
|
||||
const props = {
|
||||
postTitle: "test",
|
||||
postSlug: "/test",
|
||||
};
|
||||
|
||||
it("renders correctly", () => {
|
||||
const tree = renderer.create(<Comments {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user