add some unit tests and a gitlab ci
This commit is contained in:
		@@ -13,7 +13,7 @@ class Tag extends React.Component {
 | 
			
		||||
    render() {
 | 
			
		||||
        // todo onclick events correctlyy
 | 
			
		||||
        return (
 | 
			
		||||
            <button className='tagbtn' onClick={this.props.onClick}>{this.props.children}</button>
 | 
			
		||||
            <button className='tagbtn' onClick={this.props.onClick} data-testid="Test-Tag">{this.props.children}</button>
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								src/elements/Tag.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/elements/Tag.test.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
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);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
it('renders childs correctly', function () {
 | 
			
		||||
    const {getByTestId} = render(<Tag>test</Tag>);
 | 
			
		||||
    expect(getByTestId("Test-Tag")).toHaveTextContent("test");
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user