diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 554cf11..bae1fc1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,6 +2,7 @@ image: node:latest
stages:
- test
+ - coverage
- build
cache:
@@ -14,6 +15,14 @@ test:
- npm install
- npm run test
+coverage:
+ stage: coverage
+ script:
+ - npm run coverage
+ artifacts:
+ reports:
+ cobertura: coverage/cobertura-coverage.xml
+
build:
stage: build
script:
diff --git a/package.json b/package.json
index 9a7c96b..e766a78 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "untitled",
+ "name": "openmediacenter",
"version": "0.1.0",
"private": true,
"dependencies": {
@@ -17,8 +17,15 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
+ "coverage": "react-scripts test --coverage --watchAll=false",
"eject": "react-scripts eject"
},
+ "jest": {
+ "collectCoverageFrom": [
+ "src/**/*.{js,jsx,ts,tsx}"
+ ],
+ "coverageReporters": ["cobertura","text"]
+ },
"proxy": "http://192.168.0.248",
"homepage": "/",
"eslintConfig": {
diff --git a/src/App.test.js b/src/App.test.js
new file mode 100644
index 0000000..2092a39
--- /dev/null
+++ b/src/App.test.js
@@ -0,0 +1,28 @@
+import React from 'react';
+import { render } from '@testing-library/react';
+import App from './App';
+import ReactDom from "react-dom";
+
+describe('', function () {
+ it('renders without crashing ', function () {
+ const div = document.createElement("div");
+ ReactDom.render(,div);
+ ReactDom.unmountComponentAtNode(div);
+ });
+
+ it('renders title', () => {
+ const { getByText } = render();
+ const linkElement = getByText(/Home Page/i);
+ expect(linkElement).toBeInTheDocument();
+ });
+
+ it('are navlinks correct', function () {
+ const { getByText } = render();
+ 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();
+ });
+});
diff --git a/src/elements/Tag.test.js b/src/elements/Tag.test.js
index 7995f4e..0605251 100644
--- a/src/elements/Tag.test.js
+++ b/src/elements/Tag.test.js
@@ -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(,div);
- ReactDom.unmountComponentAtNode(div);
-});
+describe('', function () {
+ it('renders without crashing ', function () {
+ const div = document.createElement("div");
+ ReactDom.render(,div);
+ ReactDom.unmountComponentAtNode(div);
+ });
-it('renders childs correctly', function () {
- const {getByTestId} = render(test);
- expect(getByTestId("Test-Tag")).toHaveTextContent("test");
+ it('renders childs correctly', function () {
+ const {getByTestId} = render(test);
+ expect(getByTestId("Test-Tag")).toHaveTextContent("test");
+ });
});