add code coverage report

This commit is contained in:
2020-06-09 20:10:26 +02:00
parent c5f0788180
commit ea6a6dca9c
4 changed files with 56 additions and 9 deletions

28
src/App.test.js Normal file
View File

@ -0,0 +1,28 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
import ReactDom from "react-dom";
describe('<App/>', function () {
it('renders without crashing ', function () {
const div = document.createElement("div");
ReactDom.render(<App/>,div);
ReactDom.unmountComponentAtNode(div);
});
it('renders title', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/Home Page/i);
expect(linkElement).toBeInTheDocument();
});
it('are navlinks correct', function () {
const { getByText } = render(<App />);
const randomElement = getByText(/Random Video/i);
const categoryElement = getByText(/Categories/i);
const settingsElement = getByText(/Settings/i);
expect(randomElement).toBeInTheDocument();
expect(categoryElement).toBeInTheDocument();
expect(settingsElement).toBeInTheDocument();
});
});

View File

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