use enzyme library for testing updated some tests

new test for newtag component
This commit is contained in:
2020-06-10 15:41:41 +02:00
parent bb18a62a3d
commit 751e09f54b
8 changed files with 86 additions and 51 deletions

View File

@ -3,7 +3,6 @@ import React from "react";
import "./Tag.css"
class Tag extends React.Component {
constructor(props, context) {
super(props, context);

View File

@ -1,19 +1,17 @@
import React from "react";
import ReactDom from 'react-dom'
import Tag from './Tag'
import {render} from '@testing-library/react'
import "@testing-library/jest-dom"
import {shallow} from 'enzyme'
describe('<Tag/>', function () {
it('renders without crashing ', function () {
const div = document.createElement("div");
ReactDom.render(<Tag/>,div);
ReactDom.unmountComponentAtNode(div);
const wrapper = shallow(<Tag>test</Tag>);
wrapper.unmount();
});
it('renders childs correctly', function () {
const {getByTestId} = render(<Tag>test</Tag>);
expect(getByTestId("Test-Tag")).toHaveTextContent("test");
const wrapper = shallow(<Tag>test</Tag>);
expect(wrapper.children().text()).toBe("test");
});
});