rickvanlieshout.com/src/templates/category-template.test.js

33 lines
935 B
JavaScript
Raw Normal View History

2019-08-01 04:05:23 +02:00
// @flow strict
2018-11-09 18:08:48 +01:00
import React from 'react';
import renderer from 'react-test-renderer';
2019-05-09 15:57:42 +02:00
import { useStaticQuery, StaticQuery } from 'gatsby';
2018-11-09 18:08:48 +01:00
import CategoryTemplate from './category-template';
2019-05-09 15:57:42 +02:00
import siteMetadata from '../../jest/__fixtures__/site-metadata';
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
import pageContext from '../../jest/__fixtures__/page-context';
2019-05-10 01:15:43 +02:00
import type { RenderCallback } from '../types';
2018-11-09 18:08:48 +01:00
describe('CategoryTemplate', () => {
const props = {
data: {
2019-05-09 15:57:42 +02:00
...allMarkdownRemark
2018-11-09 18:08:48 +01:00
},
2019-05-09 15:57:42 +02:00
...pageContext
2018-11-09 18:08:48 +01:00
};
2019-05-09 15:57:42 +02:00
beforeEach(() => {
StaticQuery.mockImplementationOnce(
2019-05-10 01:15:43 +02:00
({ render }: RenderCallback) => (
2019-05-09 15:57:42 +02:00
render(siteMetadata)
),
useStaticQuery.mockReturnValue(siteMetadata)
);
});
2018-11-09 18:08:48 +01:00
it('renders correctly', () => {
const tree = renderer.create(<CategoryTemplate {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
});