use enzyme library for testing updated some tests
new test for newtag component
This commit is contained in:
@ -3,7 +3,6 @@ import React from "react";
|
||||
import "./Tag.css"
|
||||
|
||||
class Tag extends React.Component {
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user