Skip to content

Commit e87dee6

Browse files
authored
chore: add tests folder (#2)
1 parent b645ddc commit e87dee6

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

src/NewComponent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Here, create the new Component you want to see exported to a new package
21
import React from 'react';
32
import PropTypes from 'prop-types';
43

src/NewComponent.test.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/index.test.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/NewComponent.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import NewComponent from '../src/NewComponent';
4+
5+
const defaultProps = {
6+
children: <span>Hello</span>,
7+
};
8+
9+
const renderWithProps = (props = {}) => render(<NewComponent { ...defaultProps } { ...props } />);
10+
11+
describe('NewComponent Component', () => {
12+
it('should render correctly', () => {
13+
const { getByText } = renderWithProps();
14+
15+
expect(getByText('Hello')).toBeInTheDocument();
16+
});
17+
18+
it('should render correctly with different children', () => {
19+
const { asFragment } = renderWithProps({
20+
children: <span>Foo Bar</span>,
21+
});
22+
23+
expect(asFragment()).toMatchSnapshot();
24+
});
25+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`NewComponent Component should render correctly with different children 1`] = `
4+
<DocumentFragment>
5+
<div>
6+
<span>
7+
Foo Bar
8+
</span>
9+
</div>
10+
</DocumentFragment>
11+
`;

0 commit comments

Comments
 (0)