Skip to content

Commit

Permalink
test(ArticleComments): add snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sabertazimi committed Aug 8, 2021
1 parent 754029c commit c40074a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/Article/ArticleComments.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { create } from 'react-test-renderer';
import ArticleComments from './ArticleComments';

const commentUrl = 'https://example.com';

describe('ArticleComments', () => {
beforeAll(() => {
jest.spyOn(document, 'getElementById').mockImplementation((elementId) => {
return document.createElement(`#${elementId}`);
});
});

afterAll(() => {
(document.getElementById as unknown as jest.SpyInstance).mockRestore();
});

test('should render correctly (snapshot)', () => {
const tree = create(<ArticleComments url={commentUrl} />).toJSON();
expect(tree).toMatchSnapshot();
});
});

0 comments on commit c40074a

Please sign in to comment.