mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-09-11 18:56:15 +02:00
refactor(starter): upgrade to new version of gatsby
This commit is contained in:
41
src/components/Post/Post.test.tsx
Normal file
41
src/components/Post/Post.test.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
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);
|
||||
});
|
||||
|
||||
const props = {
|
||||
post: {
|
||||
id: "test-123",
|
||||
html: "<p>test</p>",
|
||||
fields: {
|
||||
slug: "/test",
|
||||
categorySlug: "/test-category",
|
||||
tagSlugs: ["/test_0", "/test_1"],
|
||||
},
|
||||
frontmatter: {
|
||||
date: "2016-09-01",
|
||||
tags: ["test_0", "test_1"],
|
||||
title: "test",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
it("renders correctly", () => {
|
||||
const tree = renderer.create(<Post {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user