improvement: flow coverage

This commit is contained in:
alxshelepenok
2019-05-10 02:15:43 +03:00
parent 091834f16a
commit 35f2170bf5
66 changed files with 308 additions and 56 deletions

View File

@@ -1,8 +1,18 @@
// @flow
import React from 'react';
import { withPrefix, Link } from 'gatsby';
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']}>
<Link to="/">
<img

View File

@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import renderer from 'react-test-renderer';
import Author from './Author';
@@ -8,7 +9,8 @@ describe('Author', () => {
name: 'test',
photo: '/photo.jpg',
bio: 'test'
}
},
isIndex: false
};
it('renders correctly', () => {

View File

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

View File

@@ -4,11 +4,11 @@ import { getContactHref, getIcon } from '../../../utils';
import Icon from '../../Icon';
import styles from './Contacts.module.scss';
type Props = {|
+contacts: {
type Props = {
contacts: {
[string]: string,
},
|};
};
const Contacts = ({ contacts }: Props) => (
<div className={styles['contacts']}>

View File

@@ -1,3 +1,5 @@
// @flow
import React from 'react';
import renderer from 'react-test-renderer';
import Contacts from './Contacts';

View File

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

View File

@@ -1,7 +1,12 @@
// @flow
import React from 'react';
import styles from './Copyright.module.scss';
const Copyright = ({ copyright }) => (
type Props = {
copyright: string
};
const Copyright = ({ copyright }: Props) => (
<div className={styles['copyright']}>
{copyright}
</div>

View File

@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import renderer from 'react-test-renderer';
import Copyright from './Copyright';

View File

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

View File

@@ -1,8 +1,16 @@
// @flow
import React from 'react';
import { Link } from 'gatsby';
import styles from './Menu.module.scss';
const Menu = ({ menu }) => (
type Props = {
menu: {
label: string,
path: string
}[]
};
const Menu = ({ menu }: Props) => (
<nav className={styles['menu']}>
<ul className={styles['menu__list']}>
{menu.map((item) => (

View File

@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import renderer from 'react-test-renderer';
import Menu from './Menu';

View File

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

View File

@@ -8,7 +8,7 @@ import styles from './Sidebar.module.scss';
import { useSiteMetadata } from '../../hooks';
type Props = {
+isIndex: ?boolean,
isIndex?: boolean,
};
const Sidebar = ({ isIndex }: Props) => {

View File

@@ -1,13 +1,15 @@
// @flow
import React from 'react';
import renderer from 'react-test-renderer';
import { useStaticQuery, StaticQuery } from 'gatsby';
import Sidebar from './Sidebar';
import siteMetadata from '../../../jest/__fixtures__/site-metadata';
import type { RenderCallback } from '../../types';
describe('Sidebar', () => {
beforeEach(() => {
StaticQuery.mockImplementationOnce(
({ render }) => (
({ render }: RenderCallback) => (
render(siteMetadata)
),
useStaticQuery.mockReturnValue(siteMetadata)

View File

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