mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-04-08 00:00:37 +02:00
26 lines
726 B
TypeScript
26 lines
726 B
TypeScript
import React from "react";
|
|
import renderer from "react-test-renderer";
|
|
|
|
import { StaticQuery, useStaticQuery } from "gatsby";
|
|
|
|
import { Post } from "@/components/Post";
|
|
import * as mocks from "@/mocks";
|
|
|
|
const mockedStaticQuery = StaticQuery as jest.Mock;
|
|
const mockedUseStaticQuery = useStaticQuery as jest.Mock;
|
|
|
|
describe("Post", () => {
|
|
beforeEach(() => {
|
|
mockedStaticQuery.mockImplementationOnce(({ render }) =>
|
|
render(mocks.siteMetadata),
|
|
);
|
|
mockedUseStaticQuery.mockReturnValue(mocks.siteMetadata);
|
|
});
|
|
|
|
it("renders correctly", () => {
|
|
const props = { post: mocks.markdownRemark };
|
|
const tree = renderer.create(<Post {...props} />).toJSON();
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
});
|