mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-01-12 15:01:40 +01:00
improvement: flow coverage
This commit is contained in:
parent
091834f16a
commit
35f2170bf5
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
markdownRemark: {
|
markdownRemark: {
|
||||||
|
id: 'test-123',
|
||||||
html: '<p>test</p>',
|
html: '<p>test</p>',
|
||||||
fields: {
|
fields: {
|
||||||
tagSlugs: [
|
tagSlugs: [
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import type { Entry, WidgetFor } from '../../types';
|
||||||
|
|
||||||
const PagePreview = ({ entry, widgetFor }) => {
|
type Props = {
|
||||||
|
entry: Entry,
|
||||||
|
widgetFor: WidgetFor
|
||||||
|
};
|
||||||
|
|
||||||
|
const PagePreview = ({ entry, widgetFor }: Props) => {
|
||||||
const body = widgetFor('body');
|
const body = widgetFor('body');
|
||||||
const title = entry.getIn(['data', 'title']);
|
const title = entry.getIn(['data', 'title']);
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import type { Entry, WidgetFor } from '../../types';
|
||||||
|
|
||||||
const PostPreview = ({ entry, widgetFor }) => {
|
type Props = {
|
||||||
|
entry: Entry,
|
||||||
|
widgetFor: WidgetFor
|
||||||
|
};
|
||||||
|
|
||||||
|
const PostPreview = ({ entry, widgetFor }: Props) => {
|
||||||
const body = widgetFor('body');
|
const body = widgetFor('body');
|
||||||
const title = entry.getIn(['data', 'title']);
|
const title = entry.getIn(['data', 'title']);
|
||||||
|
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
|
import type { Edges } from '../../types';
|
||||||
import styles from './Feed.module.scss';
|
import styles from './Feed.module.scss';
|
||||||
|
|
||||||
const Feed = ({ edges }) => (
|
type Props = {
|
||||||
|
edges: Edges
|
||||||
|
};
|
||||||
|
|
||||||
|
const Feed = ({ edges }: Props) => (
|
||||||
<div className={styles['feed']}>
|
<div className={styles['feed']}>
|
||||||
{edges.map((edge) => (
|
{edges.map((edge) => (
|
||||||
<div className={styles['feed__item']} key={edge.node.fields.slug}>
|
<div className={styles['feed__item']} key={edge.node.fields.slug}>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Feed from './Feed';
|
import Feed from './Feed';
|
||||||
@ -9,28 +10,50 @@ describe('Feed', () => {
|
|||||||
node: {
|
node: {
|
||||||
fields: {
|
fields: {
|
||||||
slug: '/test_0',
|
slug: '/test_0',
|
||||||
categorySlug: '/test_0'
|
categorySlug: '/test_0',
|
||||||
|
tagSlugs: [
|
||||||
|
'/test-1',
|
||||||
|
'/test-2'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
date: '2016-09-01',
|
date: '2016-09-01',
|
||||||
description: 'test_0',
|
description: 'test_0',
|
||||||
category: 'test_0',
|
category: 'test_0',
|
||||||
|
tags: [
|
||||||
|
'test-1',
|
||||||
|
'test-2'
|
||||||
|
],
|
||||||
title: 'test_0'
|
title: 'test_0'
|
||||||
}
|
},
|
||||||
|
id: 'test-123',
|
||||||
|
html: '<p>test</p>'
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
node: {
|
||||||
fields: {
|
fields: {
|
||||||
slug: '/test_1',
|
slug: '/test_1',
|
||||||
categorySlug: '/test_1'
|
categorySlug: '/test_1',
|
||||||
|
tagSlugs: [
|
||||||
|
'/test-1',
|
||||||
|
'/test-2'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
date: '2016-09-01',
|
date: '2016-09-01',
|
||||||
description: 'test_1',
|
description: 'test_1',
|
||||||
category: 'test_1',
|
category: 'test_1',
|
||||||
|
tags: [
|
||||||
|
'test-1',
|
||||||
|
'test-2'
|
||||||
|
],
|
||||||
title: 'test_1'
|
title: 'test_1'
|
||||||
}
|
},
|
||||||
|
id: 'test-321',
|
||||||
|
html: '<p>test</p>'
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Feed';
|
export { default } from './Feed';
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styles from './Icon.module.scss';
|
import styles from './Icon.module.scss';
|
||||||
|
|
||||||
const Icon = ({ icon }) => (
|
type Props = {
|
||||||
|
icon: {
|
||||||
|
viewBox?: string,
|
||||||
|
path?: string
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const Icon = ({ icon }: Props) => (
|
||||||
<svg className={styles['icon']} viewBox={icon.viewBox}>
|
<svg className={styles['icon']} viewBox={icon.viewBox}>
|
||||||
<path d={icon.path} />
|
<path d={icon.path} />
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Icon from './Icon';
|
import Icon from './Icon';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Icon';
|
export { default } from './Icon';
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
import type { Node as ReactNode } from 'react';
|
||||||
import styles from './Layout.module.scss';
|
import styles from './Layout.module.scss';
|
||||||
|
|
||||||
const Layout = ({ children, title, description }) => (
|
type Props = {
|
||||||
|
children: ReactNode,
|
||||||
|
title: string,
|
||||||
|
description?: string
|
||||||
|
};
|
||||||
|
|
||||||
|
const Layout = ({ children, title, description }: Props) => (
|
||||||
<div className={styles.layout}>
|
<div className={styles.layout}>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<html lang="en" />
|
<html lang="en" />
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Layout from './Layout';
|
import Layout from './Layout';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Layout';
|
export { default } from './Layout';
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import React, { useRef, useEffect } from 'react';
|
import React, { useRef, useEffect } from 'react';
|
||||||
import styles from './Page.module.scss';
|
import styles from './Page.module.scss';
|
||||||
|
|
||||||
const Page = ({ title, children }) => {
|
type Props = {
|
||||||
|
title?: string,
|
||||||
|
children: React.Node
|
||||||
|
};
|
||||||
|
|
||||||
|
const Page = ({ title, children }: Props) => {
|
||||||
const pageRef = useRef();
|
const pageRef = useRef();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Page from './Page';
|
import Page from './Page';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Page';
|
export { default } from './Page';
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames/bind';
|
import classNames from 'classnames/bind';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
import { PAGINATION } from '../../constants';
|
import { PAGINATION } from '../../constants';
|
||||||
import styles from './Pagination.module.scss';
|
import styles from './Pagination.module.scss';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
prevPagePath: string,
|
||||||
|
nextPagePath: string,
|
||||||
|
hasNextPage: boolean,
|
||||||
|
hasPrevPage: boolean
|
||||||
|
};
|
||||||
|
|
||||||
const cx = classNames.bind(styles);
|
const cx = classNames.bind(styles);
|
||||||
|
|
||||||
const Pagination = ({
|
const Pagination = ({
|
||||||
@ -11,7 +19,7 @@ const Pagination = ({
|
|||||||
nextPagePath,
|
nextPagePath,
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
hasPrevPage
|
hasPrevPage
|
||||||
}) => {
|
}: Props) => {
|
||||||
const prevClassName = cx({
|
const prevClassName = cx({
|
||||||
'pagination__prev-link': true,
|
'pagination__prev-link': true,
|
||||||
'pagination__prev-link--disable': !hasPrevPage
|
'pagination__prev-link--disable': !hasPrevPage
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Pagination from './Pagination';
|
import Pagination from './Pagination';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Pagination';
|
export { default } from './Pagination';
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import Author from './Author';
|
import Author from './Author';
|
||||||
import siteMetadata from '../../../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../../../jest/__fixtures__/site-metadata';
|
||||||
|
import type { RenderCallback } from '../../../types';
|
||||||
|
|
||||||
describe('Author', () => {
|
describe('Author', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDisqusComments from 'react-disqus-comments';
|
import ReactDisqusComments from 'react-disqus-comments';
|
||||||
import { useSiteMetadata } from '../../../hooks';
|
import { useSiteMetadata } from '../../../hooks';
|
||||||
|
|
||||||
const Comments = ({ postTitle, postSlug }) => {
|
type Props = {
|
||||||
|
postTitle: string,
|
||||||
|
postSlug: string
|
||||||
|
};
|
||||||
|
|
||||||
|
const Comments = ({ postTitle, postSlug }: Props) => {
|
||||||
const { url, disqusShortname } = useSiteMetadata();
|
const { url, disqusShortname } = useSiteMetadata();
|
||||||
|
|
||||||
if (!disqusShortname) {
|
if (!disqusShortname) {
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import Comments from './Comments';
|
import Comments from './Comments';
|
||||||
import siteMetadata from '../../../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../../../jest/__fixtures__/site-metadata';
|
||||||
|
import type { RenderCallback } from '../../../types';
|
||||||
|
|
||||||
describe('Comments', () => {
|
describe('Comments', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Comments';
|
export { default } from './Comments';
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styles from './Content.module.scss';
|
import styles from './Content.module.scss';
|
||||||
|
|
||||||
const Content = ({ body, title }) => (
|
type Props = {
|
||||||
|
body: string,
|
||||||
|
title: string
|
||||||
|
};
|
||||||
|
|
||||||
|
const Content = ({ body, title }: Props) => (
|
||||||
<div className={styles['content']}>
|
<div className={styles['content']}>
|
||||||
<h1 className={styles['content__title']}>{title}</h1>
|
<h1 className={styles['content__title']}>{title}</h1>
|
||||||
<div className={styles['content__body']} dangerouslySetInnerHTML={{ __html: body }} />
|
<div className={styles['content__body']} dangerouslySetInnerHTML={{ __html: body }} />
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Content from './Content';
|
import Content from './Content';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Content';
|
export { default } from './Content';
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import styles from './Meta.module.scss';
|
import styles from './Meta.module.scss';
|
||||||
|
|
||||||
const Meta = ({ date }) => (
|
type Props = {
|
||||||
|
date: string
|
||||||
|
};
|
||||||
|
|
||||||
|
const Meta = ({ date }: Props) => (
|
||||||
<div className={styles['meta']}>
|
<div className={styles['meta']}>
|
||||||
<p className={styles['meta__date']}>Published {moment(date).format('D MMM YYYY')}</p>
|
<p className={styles['meta__date']}>Published {moment(date).format('D MMM YYYY')}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Meta from './Meta';
|
import Meta from './Meta';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Meta';
|
export { default } from './Meta';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
import Author from './Author';
|
import Author from './Author';
|
||||||
@ -6,8 +7,13 @@ import Content from './Content';
|
|||||||
import Meta from './Meta';
|
import Meta from './Meta';
|
||||||
import Tags from './Tags';
|
import Tags from './Tags';
|
||||||
import styles from './Post.module.scss';
|
import styles from './Post.module.scss';
|
||||||
|
import type { Node } from '../../types';
|
||||||
|
|
||||||
const Post = ({ post }) => {
|
type Props = {
|
||||||
|
post: Node
|
||||||
|
};
|
||||||
|
|
||||||
|
const Post = ({ post }: Props) => {
|
||||||
const { html } = post;
|
const { html } = post;
|
||||||
const { tagSlugs, slug } = post.fields;
|
const { tagSlugs, slug } = post.fields;
|
||||||
const { tags, title, date } = post.frontmatter;
|
const { tags, title, date } = post.frontmatter;
|
||||||
@ -22,7 +28,7 @@ const Post = ({ post }) => {
|
|||||||
|
|
||||||
<div className={styles['post__footer']}>
|
<div className={styles['post__footer']}>
|
||||||
<Meta date={date} />
|
<Meta date={date} />
|
||||||
{tags && <Tags tags={tags} tagSlugs={tagSlugs} />}
|
{tags && tagSlugs && <Tags tags={tags} tagSlugs={tagSlugs} />}
|
||||||
<Author />
|
<Author />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import Post from './Post';
|
import Post from './Post';
|
||||||
import siteMetadata from '../../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../../jest/__fixtures__/site-metadata';
|
||||||
|
import type { RenderCallback } from '../../types';
|
||||||
|
|
||||||
describe('Post', () => {
|
describe('Post', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
@ -16,8 +18,11 @@ describe('Post', () => {
|
|||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
post: {
|
post: {
|
||||||
|
id: 'test-123',
|
||||||
html: '<p>test</p>',
|
html: '<p>test</p>',
|
||||||
fields: {
|
fields: {
|
||||||
|
slug: '/test',
|
||||||
|
categorySlug: '/test-category',
|
||||||
tagSlugs: [
|
tagSlugs: [
|
||||||
'/test_0',
|
'/test_0',
|
||||||
'/test_1'
|
'/test_1'
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
import styles from './Tags.module.scss';
|
import styles from './Tags.module.scss';
|
||||||
|
|
||||||
const Tags = ({ tags, tagSlugs }) => (
|
type Props = {
|
||||||
|
tags: string[],
|
||||||
|
tagSlugs: string[]
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tags = ({ tags, tagSlugs }: Props) => (
|
||||||
<div className={styles['tags']}>
|
<div className={styles['tags']}>
|
||||||
<ul className={styles['tags__list']}>
|
<ul className={styles['tags__list']}>
|
||||||
{tagSlugs.map((slug, i) => (
|
{tagSlugs && tagSlugs.map((slug, i) => (
|
||||||
<li className={styles['tags__list-item']} key={tags[i]}>
|
<li className={styles['tags__list-item']} key={tags[i]}>
|
||||||
<Link to={slug} className={styles['tags__list-item-link']}>
|
<Link to={slug} className={styles['tags__list-item-link']}>
|
||||||
{tags[i]}
|
{tags[i]}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Tags from './Tags';
|
import Tags from './Tags';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Tags';
|
export { default } from './Tags';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Post';
|
export { default } from './Post';
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { withPrefix, Link } from 'gatsby';
|
import { withPrefix, Link } from 'gatsby';
|
||||||
import styles from './Author.module.scss';
|
import styles from './Author.module.scss';
|
||||||
|
|
||||||
const Author = ({ author, isIndex }) => (
|
type Props = {
|
||||||
|
author: {
|
||||||
|
name: string,
|
||||||
|
bio: string,
|
||||||
|
photo: string
|
||||||
|
},
|
||||||
|
isIndex: ?boolean
|
||||||
|
};
|
||||||
|
|
||||||
|
const Author = ({ author, isIndex }: Props) => (
|
||||||
<div className={styles['author']}>
|
<div className={styles['author']}>
|
||||||
<Link to="/">
|
<Link to="/">
|
||||||
<img
|
<img
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Author from './Author';
|
import Author from './Author';
|
||||||
@ -8,7 +9,8 @@ describe('Author', () => {
|
|||||||
name: 'test',
|
name: 'test',
|
||||||
photo: '/photo.jpg',
|
photo: '/photo.jpg',
|
||||||
bio: 'test'
|
bio: 'test'
|
||||||
}
|
},
|
||||||
|
isIndex: false
|
||||||
};
|
};
|
||||||
|
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Author';
|
export { default } from './Author';
|
||||||
|
@ -4,11 +4,11 @@ import { getContactHref, getIcon } from '../../../utils';
|
|||||||
import Icon from '../../Icon';
|
import Icon from '../../Icon';
|
||||||
import styles from './Contacts.module.scss';
|
import styles from './Contacts.module.scss';
|
||||||
|
|
||||||
type Props = {|
|
type Props = {
|
||||||
+contacts: {
|
contacts: {
|
||||||
[string]: string,
|
[string]: string,
|
||||||
},
|
},
|
||||||
|};
|
};
|
||||||
|
|
||||||
const Contacts = ({ contacts }: Props) => (
|
const Contacts = ({ contacts }: Props) => (
|
||||||
<div className={styles['contacts']}>
|
<div className={styles['contacts']}>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Contacts from './Contacts';
|
import Contacts from './Contacts';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Contacts';
|
export { default } from './Contacts';
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styles from './Copyright.module.scss';
|
import styles from './Copyright.module.scss';
|
||||||
|
|
||||||
const Copyright = ({ copyright }) => (
|
type Props = {
|
||||||
|
copyright: string
|
||||||
|
};
|
||||||
|
|
||||||
|
const Copyright = ({ copyright }: Props) => (
|
||||||
<div className={styles['copyright']}>
|
<div className={styles['copyright']}>
|
||||||
{copyright}
|
{copyright}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Copyright from './Copyright';
|
import Copyright from './Copyright';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Copyright';
|
export { default } from './Copyright';
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
import styles from './Menu.module.scss';
|
import styles from './Menu.module.scss';
|
||||||
|
|
||||||
const Menu = ({ menu }) => (
|
type Props = {
|
||||||
|
menu: {
|
||||||
|
label: string,
|
||||||
|
path: string
|
||||||
|
}[]
|
||||||
|
};
|
||||||
|
|
||||||
|
const Menu = ({ menu }: Props) => (
|
||||||
<nav className={styles['menu']}>
|
<nav className={styles['menu']}>
|
||||||
<ul className={styles['menu__list']}>
|
<ul className={styles['menu__list']}>
|
||||||
{menu.map((item) => (
|
{menu.map((item) => (
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import Menu from './Menu';
|
import Menu from './Menu';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Menu';
|
export { default } from './Menu';
|
||||||
|
@ -8,7 +8,7 @@ import styles from './Sidebar.module.scss';
|
|||||||
import { useSiteMetadata } from '../../hooks';
|
import { useSiteMetadata } from '../../hooks';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
+isIndex: ?boolean,
|
isIndex?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Sidebar = ({ isIndex }: Props) => {
|
const Sidebar = ({ isIndex }: Props) => {
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import Sidebar from './Sidebar';
|
import Sidebar from './Sidebar';
|
||||||
import siteMetadata from '../../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../../jest/__fixtures__/site-metadata';
|
||||||
|
import type { RenderCallback } from '../../types';
|
||||||
|
|
||||||
describe('Sidebar', () => {
|
describe('Sidebar', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @flow
|
||||||
export { default } from './Sidebar';
|
export { default } from './Sidebar';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
import kebabCase from 'lodash/kebabCase';
|
import kebabCase from 'lodash/kebabCase';
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import CategoriesListTemplate from './categories-list-template';
|
import CategoriesListTemplate from './categories-list-template';
|
||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('CategoriesListTemplate', () => {
|
describe('CategoriesListTemplate', () => {
|
||||||
const props = {
|
const props = {
|
||||||
@ -13,7 +15,7 @@ describe('CategoriesListTemplate', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(props)
|
render(props)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(props)
|
useStaticQuery.mockReturnValue(props)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { graphql } from 'gatsby';
|
import { graphql } from 'gatsby';
|
||||||
import Layout from '../components/Layout';
|
import Layout from '../components/Layout';
|
||||||
@ -6,8 +7,14 @@ import Feed from '../components/Feed';
|
|||||||
import Page from '../components/Page';
|
import Page from '../components/Page';
|
||||||
import Pagination from '../components/Pagination';
|
import Pagination from '../components/Pagination';
|
||||||
import { useSiteMetadata } from '../hooks';
|
import { useSiteMetadata } from '../hooks';
|
||||||
|
import type { PageContext, AllMarkdownRemark } from '../types';
|
||||||
|
|
||||||
const CategoryTemplate = ({ data, pageContext }) => {
|
type Props = {
|
||||||
|
data: AllMarkdownRemark,
|
||||||
|
pageContext: PageContext
|
||||||
|
};
|
||||||
|
|
||||||
|
const CategoryTemplate = ({ data, pageContext }: Props) => {
|
||||||
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
@ -5,6 +6,7 @@ import CategoryTemplate from './category-template';
|
|||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
||||||
import pageContext from '../../jest/__fixtures__/page-context';
|
import pageContext from '../../jest/__fixtures__/page-context';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('CategoryTemplate', () => {
|
describe('CategoryTemplate', () => {
|
||||||
const props = {
|
const props = {
|
||||||
@ -16,7 +18,7 @@ describe('CategoryTemplate', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -7,10 +7,11 @@ import Feed from '../components/Feed';
|
|||||||
import Page from '../components/Page';
|
import Page from '../components/Page';
|
||||||
import Pagination from '../components/Pagination';
|
import Pagination from '../components/Pagination';
|
||||||
import { useSiteMetadata } from '../hooks';
|
import { useSiteMetadata } from '../hooks';
|
||||||
|
import type { PageContext, AllMarkdownRemark } from '../types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
+data: Object,
|
data: AllMarkdownRemark,
|
||||||
+pageContext: Object,
|
pageContext: PageContext
|
||||||
};
|
};
|
||||||
|
|
||||||
const IndexTemplate = ({ data, pageContext }: Props) => {
|
const IndexTemplate = ({ data, pageContext }: Props) => {
|
||||||
@ -46,12 +47,6 @@ const IndexTemplate = ({ data, pageContext }: Props) => {
|
|||||||
|
|
||||||
export const query = graphql`
|
export const query = graphql`
|
||||||
query IndexTemplate($postsLimit: Int!, $postsOffset: Int!) {
|
query IndexTemplate($postsLimit: Int!, $postsOffset: Int!) {
|
||||||
site {
|
|
||||||
siteMetadata {
|
|
||||||
title
|
|
||||||
subtitle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
allMarkdownRemark(
|
allMarkdownRemark(
|
||||||
limit: $postsLimit,
|
limit: $postsLimit,
|
||||||
skip: $postsOffset,
|
skip: $postsOffset,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { StaticQuery, useStaticQuery } from 'gatsby';
|
import { StaticQuery, useStaticQuery } from 'gatsby';
|
||||||
@ -5,6 +6,7 @@ import IndexTemplate from './index-template';
|
|||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
||||||
import pageContext from '../../jest/__fixtures__/page-context';
|
import pageContext from '../../jest/__fixtures__/page-context';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('IndexTemplate', () => {
|
describe('IndexTemplate', () => {
|
||||||
const props = {
|
const props = {
|
||||||
@ -16,7 +18,7 @@ describe('IndexTemplate', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Sidebar from '../components/Sidebar';
|
import Sidebar from '../components/Sidebar';
|
||||||
import Layout from '../components/Layout';
|
import Layout from '../components/Layout';
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import NotFoundTemplate from './not-found-template';
|
import NotFoundTemplate from './not-found-template';
|
||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('NotFoundTemplate', () => {
|
describe('NotFoundTemplate', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { graphql } from 'gatsby';
|
import { graphql } from 'gatsby';
|
||||||
import Layout from '../components/Layout';
|
import Layout from '../components/Layout';
|
||||||
import Sidebar from '../components/Sidebar';
|
import Sidebar from '../components/Sidebar';
|
||||||
import Page from '../components/Page';
|
import Page from '../components/Page';
|
||||||
import { useSiteMetadata } from '../hooks';
|
import { useSiteMetadata } from '../hooks';
|
||||||
|
import type { MarkdownRemark } from '../types';
|
||||||
|
|
||||||
const PageTemplate = ({ data }) => {
|
type Props = {
|
||||||
|
data: {
|
||||||
|
markdownRemark: MarkdownRemark
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const PageTemplate = ({ data }: Props) => {
|
||||||
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
||||||
const { html: pageBody } = data.markdownRemark;
|
const { html: pageBody } = data.markdownRemark;
|
||||||
const { title: pageTitle, description: pageDescription } = data.markdownRemark.frontmatter;
|
const { title: pageTitle, description: pageDescription } = data.markdownRemark.frontmatter;
|
||||||
@ -23,12 +31,6 @@ const PageTemplate = ({ data }) => {
|
|||||||
|
|
||||||
export const query = graphql`
|
export const query = graphql`
|
||||||
query PageBySlug($slug: String!) {
|
query PageBySlug($slug: String!) {
|
||||||
site {
|
|
||||||
siteMetadata {
|
|
||||||
title
|
|
||||||
subtitle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
markdownRemark(fields: { slug: { eq: $slug } }) {
|
markdownRemark(fields: { slug: { eq: $slug } }) {
|
||||||
id
|
id
|
||||||
html
|
html
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import PageTemplate from './page-template';
|
import PageTemplate from './page-template';
|
||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import markdownRemark from '../../jest/__fixtures__/markdown-remark';
|
import markdownRemark from '../../jest/__fixtures__/markdown-remark';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('PageTemplate', () => {
|
describe('PageTemplate', () => {
|
||||||
const props = {
|
const props = {
|
||||||
@ -14,7 +16,7 @@ describe('PageTemplate', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -3,8 +3,13 @@ import { graphql } from 'gatsby';
|
|||||||
import Layout from '../components/Layout';
|
import Layout from '../components/Layout';
|
||||||
import Post from '../components/Post';
|
import Post from '../components/Post';
|
||||||
import { useSiteMetadata } from '../hooks';
|
import { useSiteMetadata } from '../hooks';
|
||||||
|
import type { MarkdownRemark } from '../types';
|
||||||
|
|
||||||
const PostTemplate = ({ data }) => {
|
type Props = {
|
||||||
|
data: MarkdownRemark
|
||||||
|
};
|
||||||
|
|
||||||
|
const PostTemplate = ({ data }: Props) => {
|
||||||
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
||||||
const { title: postTitle, description: postDescription } = data.markdownRemark.frontmatter;
|
const { title: postTitle, description: postDescription } = data.markdownRemark.frontmatter;
|
||||||
const metaDescription = postDescription !== null ? postDescription : siteSubtitle;
|
const metaDescription = postDescription !== null ? postDescription : siteSubtitle;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import PostTemplate from './post-template';
|
import PostTemplate from './post-template';
|
||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import markdownRemark from '../../jest/__fixtures__/markdown-remark';
|
import markdownRemark from '../../jest/__fixtures__/markdown-remark';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('PostTemplate', () => {
|
describe('PostTemplate', () => {
|
||||||
const props = {
|
const props = {
|
||||||
@ -14,7 +16,7 @@ describe('PostTemplate', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { graphql } from 'gatsby';
|
import { graphql } from 'gatsby';
|
||||||
import Layout from '../components/Layout';
|
import Layout from '../components/Layout';
|
||||||
@ -6,8 +7,14 @@ import Feed from '../components/Feed';
|
|||||||
import Page from '../components/Page';
|
import Page from '../components/Page';
|
||||||
import Pagination from '../components/Pagination';
|
import Pagination from '../components/Pagination';
|
||||||
import { useSiteMetadata } from '../hooks';
|
import { useSiteMetadata } from '../hooks';
|
||||||
|
import type { AllMarkdownRemark, PageContext } from '../types';
|
||||||
|
|
||||||
const TagTemplate = ({ data, pageContext }) => {
|
type Props = {
|
||||||
|
data: AllMarkdownRemark,
|
||||||
|
pageContext: PageContext
|
||||||
|
};
|
||||||
|
|
||||||
|
const TagTemplate = ({ data, pageContext }: Props) => {
|
||||||
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
@ -5,11 +6,12 @@ import TagTemplate from './tag-template';
|
|||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
||||||
import pageContext from '../../jest/__fixtures__/page-context';
|
import pageContext from '../../jest/__fixtures__/page-context';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('TagTemplate', () => {
|
describe('TagTemplate', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(siteMetadata)
|
render(siteMetadata)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(siteMetadata)
|
useStaticQuery.mockReturnValue(siteMetadata)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'gatsby';
|
import { Link } from 'gatsby';
|
||||||
import kebabCase from 'lodash/kebabCase';
|
import kebabCase from 'lodash/kebabCase';
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { useStaticQuery, StaticQuery } from 'gatsby';
|
import { useStaticQuery, StaticQuery } from 'gatsby';
|
||||||
import TagsListTemplate from './tags-list-template';
|
import TagsListTemplate from './tags-list-template';
|
||||||
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
import siteMetadata from '../../jest/__fixtures__/site-metadata';
|
||||||
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
|
||||||
|
import type { RenderCallback } from '../types';
|
||||||
|
|
||||||
describe('TagsListTemplate', () => {
|
describe('TagsListTemplate', () => {
|
||||||
const props = {
|
const props = {
|
||||||
@ -13,7 +15,7 @@ describe('TagsListTemplate', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
StaticQuery.mockImplementationOnce(
|
StaticQuery.mockImplementationOnce(
|
||||||
({ render }) => (
|
({ render }: RenderCallback) => (
|
||||||
render(props)
|
render(props)
|
||||||
),
|
),
|
||||||
useStaticQuery.mockReturnValue(props)
|
useStaticQuery.mockReturnValue(props)
|
||||||
|
53
src/types/index.js
Normal file
53
src/types/index.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// @flow
|
||||||
|
import type { Node as ReactNode } from 'react';
|
||||||
|
|
||||||
|
export type RenderCallback = (data: any) => ReactNode;
|
||||||
|
|
||||||
|
export type Entry = (string[]) => string;
|
||||||
|
|
||||||
|
export type WidgetFor = (string) => string;
|
||||||
|
|
||||||
|
export type PageContext = {
|
||||||
|
tag: string,
|
||||||
|
category: string,
|
||||||
|
currentPage: number,
|
||||||
|
prevPagePath: string,
|
||||||
|
nextPagePath: string,
|
||||||
|
hasPrevPage: boolean,
|
||||||
|
hasNextPage: boolean
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Node = {
|
||||||
|
fields: {
|
||||||
|
slug: string,
|
||||||
|
categorySlug?: string,
|
||||||
|
tagSlugs?: string[]
|
||||||
|
},
|
||||||
|
frontmatter: {
|
||||||
|
date: string,
|
||||||
|
description?: string,
|
||||||
|
category?: string,
|
||||||
|
tags?: string[],
|
||||||
|
title: string,
|
||||||
|
},
|
||||||
|
html: string,
|
||||||
|
id: string
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Edge = {
|
||||||
|
node: Node
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Edges = Array<Edge>;
|
||||||
|
|
||||||
|
export type AllMarkdownRemark = {
|
||||||
|
allMarkdownRemark: {
|
||||||
|
edges: Edges,
|
||||||
|
},
|
||||||
|
group: {
|
||||||
|
fieldValue: string,
|
||||||
|
totalCount: number
|
||||||
|
}[]
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MarkdownRemark = Node;
|
Loading…
Reference in New Issue
Block a user