-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'web-client' into develop
- Loading branch information
Showing
8 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'bootstrap/dist/css/bootstrap.min.css' | ||
|
||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import { createStore } from 'redux' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import allReducers from '../../redux' | ||
import CustomCenteredButton from './CustomCenteredButton' | ||
const store = createStore(allReducers) | ||
const text = "button text" | ||
|
||
function renderButton(text, onClick){ | ||
render( | ||
<Provider store={store}> | ||
<CustomCenteredButton text = { text } onClick = { onClick }/> | ||
</Provider> | ||
) | ||
} | ||
|
||
test("Expecting text to be correct", () => { | ||
renderButton(text, () => {}) | ||
expect(screen.getByText(text)).toBeInTheDocument() | ||
}) | ||
|
||
test("Expecting button to execute on click", () => { | ||
let flag = false | ||
renderButton(text, () => { flag = true }) | ||
expect(flag).toBe(false) | ||
screen.getByText(text).click() | ||
expect(flag).toBe(true) | ||
}) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'bootstrap/dist/css/bootstrap.min.css' | ||
|
||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import { createStore } from 'redux' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import allReducers from '../../../redux' | ||
import FormButton from './FormButton' | ||
const store = createStore(allReducers) | ||
const text = "button text" | ||
|
||
function renderButton(text, onClick){ | ||
render( | ||
<Provider store={store}> | ||
<FormButton text = { text } onClick = { onClick }/> | ||
</Provider> | ||
) | ||
} | ||
|
||
test("Expecting text to be correct", () => { | ||
renderButton(text, () => {}) | ||
expect(screen.getByText(text)).toBeInTheDocument() | ||
}) | ||
|
||
test("Expecting button to execute on click", () => { | ||
let flag = false | ||
renderButton(text, () => { flag = true }) | ||
expect(flag).toBe(false) | ||
screen.getByText(text).click() | ||
expect(flag).toBe(true) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'bootstrap/dist/css/bootstrap.min.css' | ||
|
||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import { createStore } from 'redux' | ||
import { render, screen } from '@testing-library/react' | ||
import userEvent from '@testing-library/user-event' | ||
|
||
import allReducers from '../../../../redux' | ||
import FormInput from './FormInput' | ||
const store = createStore(allReducers) | ||
const text = "button text" | ||
const placeholder = "button placeholder" | ||
|
||
function renderButton(onChange){ | ||
render( | ||
<Provider store={store}> | ||
<FormInput type = { "text" } text = { text } placeholder = { placeholder } onChange = { onChange }/> | ||
</Provider> | ||
) | ||
} | ||
|
||
test("Expecting text to be rendered", () => { | ||
renderButton(() => {}) | ||
expect(screen.getByText(text)).toBeInTheDocument() | ||
}) | ||
|
||
test("Expecting placeholder to be rendered", () => { | ||
renderButton(() => {}) | ||
expect(screen.getByPlaceholderText(placeholder)).toBeInTheDocument() | ||
}) | ||
|
||
test("Expecting value to be updated typing", () => { | ||
const stringToType = "hello, test!" | ||
let typed = "" | ||
renderButton(input => { typed = input }) | ||
expect(typed).toBe("") | ||
userEvent.type(screen.getByPlaceholderText(placeholder), stringToType) | ||
expect(typed).toBe(stringToType) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters