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

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