rickvanlieshout.com/src/templates/tag-template.test.js
2019-07-31 22:05:23 -04:00

33 lines
915 B
JavaScript

// @flow strict
import React from 'react';
import renderer from 'react-test-renderer';
import { useStaticQuery, StaticQuery } from 'gatsby';
import TagTemplate from './tag-template';
import siteMetadata from '../../jest/__fixtures__/site-metadata';
import allMarkdownRemark from '../../jest/__fixtures__/all-markdown-remark';
import pageContext from '../../jest/__fixtures__/page-context';
import type { RenderCallback } from '../types';
describe('TagTemplate', () => {
beforeEach(() => {
StaticQuery.mockImplementationOnce(
({ render }: RenderCallback) => (
render(siteMetadata)
),
useStaticQuery.mockReturnValue(siteMetadata)
);
});
const props = {
data: {
...allMarkdownRemark
},
...pageContext
};
it('renders correctly', () => {
const tree = renderer.create(<TagTemplate {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
});