mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-08-08 02:18:11 +02:00
improvement: flow coverage
This commit is contained in:
@@ -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
|
||||
|
@@ -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', () => {
|
||||
|
@@ -1 +1,2 @@
|
||||
// @flow
|
||||
export { default } from './Author';
|
||||
|
@@ -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']}>
|
||||
|
@@ -1,3 +1,5 @@
|
||||
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import Contacts from './Contacts';
|
||||
|
@@ -1 +1,2 @@
|
||||
// @flow
|
||||
export { default } from './Contacts';
|
||||
|
@@ -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>
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import Copyright from './Copyright';
|
||||
|
@@ -1 +1,2 @@
|
||||
// @flow
|
||||
export { default } from './Copyright';
|
||||
|
@@ -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) => (
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import Menu from './Menu';
|
||||
|
@@ -1 +1,2 @@
|
||||
// @flow
|
||||
export { default } from './Menu';
|
||||
|
@@ -8,7 +8,7 @@ import styles from './Sidebar.module.scss';
|
||||
import { useSiteMetadata } from '../../hooks';
|
||||
|
||||
type Props = {
|
||||
+isIndex: ?boolean,
|
||||
isIndex?: boolean,
|
||||
};
|
||||
|
||||
const Sidebar = ({ isIndex }: Props) => {
|
||||
|
@@ -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)
|
||||
|
@@ -1 +1,2 @@
|
||||
// @flow
|
||||
export { default } from './Sidebar';
|
||||
|
Reference in New Issue
Block a user