refactor(starter): upgrade to new version of gatsby

This commit is contained in:
Alexander Shelepenok
2022-01-09 20:12:31 +00:00
parent 84bdc5899d
commit 67ebabbaac
397 changed files with 26665 additions and 34984 deletions

View File

@@ -1,27 +0,0 @@
// @flow strict
import React from 'react';
import { getContactHref } from '../../../utils';
import styles from './Author.module.scss';
import { useSiteMetadata } from '../../../hooks';
const Author = () => {
const { author } = useSiteMetadata();
return (
<div className={styles['author']}>
<p className={styles['author__bio']}>
{author.bio}
<a
className={styles['author__bio-twitter']}
href={getContactHref('twitter', author.contacts.twitter)}
rel="noopener noreferrer"
target="_blank"
>
<strong>{author.name}</strong> on Twitter
</a>
</p>
</div>
);
};
export default Author;

View File

@@ -1,5 +1,5 @@
@import '../../../assets/scss/variables';
@import '../../../assets/scss/mixins';
@import "../../../assets/scss/variables";
@import "../../../assets/scss/mixins";
.author {
border-top: 1px solid $color-gray-border;
@@ -22,5 +22,4 @@
margin-left: auto;
margin-right: auto;
}
}
}

View File

@@ -1,23 +0,0 @@
// @flow strict
import React from 'react';
import renderer from 'react-test-renderer';
import { useStaticQuery, StaticQuery } from 'gatsby';
import Author from './Author';
import siteMetadata from '../../../../jest/__fixtures__/site-metadata';
import type { RenderCallback } from '../../../types';
describe('Author', () => {
beforeEach(() => {
StaticQuery.mockImplementationOnce(
({ render }: RenderCallback) => (
render(siteMetadata)
),
useStaticQuery.mockReturnValue(siteMetadata)
);
});
it('renders correctly', () => {
const tree = renderer.create(<Author />).toJSON();
expect(tree).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,25 @@
import React from "react";
import renderer from "react-test-renderer";
import { StaticQuery, useStaticQuery } from "gatsby";
import { Author } from "@/components/Post/Author";
import * as mocks from "@/mocks";
const mockedStaticQuery = StaticQuery as jest.Mock;
const mockedUseStaticQuery = useStaticQuery as jest.Mock;
describe("Author", () => {
console.log(mockedStaticQuery);
beforeEach(() => {
mockedStaticQuery.mockImplementationOnce(({ render }) =>
render(mocks.siteMetadata),
);
mockedUseStaticQuery.mockReturnValue(mocks.siteMetadata);
});
it("renders correctly", () => {
const tree = renderer.create(<Author />).toJSON();
expect(tree).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,28 @@
import React from "react";
import { useSiteMetadata } from "@/hooks";
import { getContactHref } from "@/utils";
import styles from "./Author.module.scss";
const Author = () => {
const { author } = useSiteMetadata();
return (
<div className={styles.author}>
<p className={styles.author__bio}>
{author.bio}
<a
className={styles["author__bio-twitter"]}
href={getContactHref("twitter", author.contacts.twitter)}
rel="noopener noreferrer"
target="_blank"
>
<strong>{author.name}</strong> on Twitter
</a>
</p>
</div>
);
};
export default Author;

View File

@@ -7,7 +7,7 @@ exports[`Author renders correctly 1`] = `
<p
className="author__bio"
>
Test bio
Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu.
<a
className="author__bio-twitter"
href="https://www.twitter.com/#"
@@ -15,7 +15,7 @@ exports[`Author renders correctly 1`] = `
target="_blank"
>
<strong>
Test name
John Doe
</strong>
on Twitter
</a>

View File

@@ -1,2 +0,0 @@
// @flow strict
export { default } from './Author';

View File

@@ -0,0 +1 @@
export { default as Author } from "./Author";