Skip to content

Commit

Permalink
Merge pull request #26 from skwirowski/12-ui-red-button
Browse files Browse the repository at this point in the history
[#12] UI Red Button
  • Loading branch information
Dominik Smutek authored Dec 31, 2020
2 parents 687a7a3 + 49e7a58 commit 9bbd04a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {redButton} from './redButton'

export const App = ({options}) => {
redButton('play the game');
}


10 changes: 10 additions & 0 deletions src/app/redButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const redButton = (text) => {
const app = document.querySelector('#swquiz-app');
const button = document.createElement('button');
let buttonText = document.createTextNode(`${text}`);
button.setAttribute('id', 'red-button');
button.setAttribute('class', 'button button--red button--uppercase');
button.setAttribute('data-testid', 'red-button');
button.appendChild(buttonText);
app.appendChild(button);
}
19 changes: 19 additions & 0 deletions styles/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,22 @@ body {
font-family: 'Montserrat', sans-serif;
padding: 0 5vw;
}

.button {
border-radius: 16px;
font-size: 42px;
font-weight: 500;
height: 100px;
line-height: 51.2px;
width: 600px;
}

.button--red {
background: rgba(255, 0, 0, 0.8);
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
color: #fff;
}

.button--uppercase {
text-transform: uppercase;
}
26 changes: 26 additions & 0 deletions test/redButton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { redButton } from '../src/app/redButton'
import { screen } from '@testing-library/dom'
import '@testing-library/jest-dom/extend-expect';

test('button has class button button--red button--uppercase', () => {
document.body.innerHTML = `<div id="swquiz-app"></div>`;
const testText = 'play the game';
redButton(testText);
expect(screen.getByTestId('red-button')).toHaveClass('button button--red button--uppercase');
})

test('button has text', () => {
document.body.innerHTML = `<div id="swquiz-app"></div>`;
const testText = 'play the game';
redButton(testText);
expect(screen.getByTestId('red-button')).not.toBeEmptyDOMElement();
})

test('button has text - play the game', () => {
document.body.innerHTML = `<div id="swquiz-app"></div>`;
const testText = 'play the game';
redButton(testText);
expect(screen.getByTestId('red-button')).toHaveTextContent('play the game');
})


0 comments on commit 9bbd04a

Please sign in to comment.