mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-09-20 15:10:15 +02:00
refactor(starter): upgrade to new version of gatsby
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
// @flow strict
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||
import Comments from './Comments';
|
||||
import siteMetadata from '../../../../jest/__fixtures__/site-metadata';
|
||||
import type { RenderCallback } from '../../../types';
|
||||
|
||||
describe('Comments', () => {
|
||||
beforeEach(() => {
|
||||
StaticQuery.mockImplementationOnce(
|
||||
({ render }: RenderCallback) => (
|
||||
render(siteMetadata)
|
||||
),
|
||||
useStaticQuery.mockReturnValue(siteMetadata)
|
||||
);
|
||||
});
|
||||
|
||||
const props = {
|
||||
postTitle: 'test',
|
||||
postSlug: '/test'
|
||||
};
|
||||
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer.create(<Comments {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
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();
|
||||
});
|
||||
});
|
@@ -1,14 +1,14 @@
|
||||
// @flow strict
|
||||
import React from 'react';
|
||||
import ReactDisqusComments from 'react-disqus-comments';
|
||||
import { useSiteMetadata } from '../../../hooks';
|
||||
import React from "react";
|
||||
import ReactDisqusComments from "react-disqus-comments";
|
||||
|
||||
type Props = {
|
||||
postTitle: string,
|
||||
postSlug: string
|
||||
};
|
||||
import { useSiteMetadata } from "@/hooks";
|
||||
|
||||
const Comments = ({ postTitle, postSlug }: Props) => {
|
||||
interface Props {
|
||||
postTitle: string;
|
||||
postSlug: string;
|
||||
}
|
||||
|
||||
const Comments: React.FC<Props> = ({ postTitle, postSlug }: Props) => {
|
||||
const { url, disqusShortname } = useSiteMetadata();
|
||||
|
||||
if (!disqusShortname) {
|
@@ -1,2 +0,0 @@
|
||||
// @flow strict
|
||||
export { default } from './Comments';
|
1
src/components/Post/Comments/index.ts
Normal file
1
src/components/Post/Comments/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as Comments } from "./Comments";
|
Reference in New Issue
Block a user