-
Notifications
You must be signed in to change notification settings - Fork 0
Semana12 aula4 week planner #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| node_modules/ | ||
| /.pnp | ||
| .pnp.js | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| { | ||
| "name": "planner-boilerplate", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "keywords": [], | ||
| "main": "src/index.js", | ||
| "dependencies": { | ||
| "@material-ui/core": "3.9.3", | ||
| "axios": "0.19.0", | ||
| "connected-react-router": "6.5.2", | ||
| "history": "4.10.1", | ||
| "react": "16.8.6", | ||
| "react-dom": "16.8.6", | ||
| "react-redux": "7.1.1", | ||
| "react-scripts": "^3.3.0", | ||
| "redux": "4.0.4", | ||
| "redux-thunk": "2.3.0", | ||
| "styled-components": "4.4.1" | ||
| }, | ||
| "devDependencies": { | ||
| "react-test-renderer": "^16.8.6", | ||
| "typescript": "3.3.3" | ||
| }, | ||
| "scripts": { | ||
| "start": "react-scripts start", | ||
| "build": "react-scripts build", | ||
| "test": "react-scripts test --env=jsdom", | ||
| "eject": "react-scripts eject" | ||
| }, | ||
| "browserslist": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not ie <= 11", | ||
| "not op_mini all" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta | ||
| name="viewport" | ||
| content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" | ||
| /> | ||
| <meta name="theme-color" content="#000000" /> | ||
| <!-- | ||
| manifest.json provides metadata used when your web app is added to the | ||
| homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
| --> | ||
| <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
| <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
| <!-- | ||
| Notice the use of %PUBLIC_URL% in the tags above. | ||
| It will be replaced with the URL of the `public` folder during the build. | ||
| Only files inside the `public` folder can be referenced from the HTML. | ||
|
|
||
| Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
| work correctly both with client-side routing and a non-root public URL. | ||
| Learn how to configure a non-root public URL by running `npm run build`. | ||
| --> | ||
| <title>Week Planner</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <noscript> | ||
| You need to enable JavaScript to run this app. | ||
| </noscript> | ||
| <div id="root"></div> | ||
| <!-- | ||
| This HTML file is a template. | ||
| If you open it directly in the browser, you will see an empty page. | ||
|
|
||
| You can add webfonts, meta tags, or analytics to this file. | ||
| The build step will place the bundled scripts into the <body> tag. | ||
|
|
||
| To begin the development, run `npm start` or `yarn start`. | ||
| To create a production bundle, use `npm run build` or `yarn build`. | ||
| --> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import axios from 'axios'; | ||
|
|
||
| const baseUrl = "https://us-central1-missao-newton.cloudfunctions.net/generic/planner-bouman-brian" | ||
|
|
||
| export const setTaskDayAction = (task) => ({ | ||
| type: "SET_TASK_DAY_ACTION", | ||
| payload: { | ||
| task, | ||
| } | ||
| }) | ||
|
|
||
| export const getTasks = () => async (dispatch) => { | ||
|
|
||
| const response = await axios.get(`${baseUrl}`) | ||
| dispatch(setTaskDayAction(response.data)) | ||
| } | ||
|
|
||
| export const createTask = (text, day) => async (dispatch) => { | ||
|
|
||
| const newTask = { | ||
| text, | ||
| day | ||
| } | ||
|
|
||
| const response = await axios.post(`${baseUrl}`, newTask) | ||
|
|
||
| if(response.status === 200) { | ||
|
|
||
| dispatch(getTasks()) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import {setTaskDayAction, getTasks, createTask} from '.' | ||
| import axios from 'axios'; | ||
|
|
||
| const tasks = [{ | ||
| id: 1, | ||
| text: 'helloWorld', | ||
| day: 'Segunda' | ||
| }] | ||
|
|
||
| describe('Teste das actions', () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Não precisa explicitar que é um teste. E é uma boa deixar claro qual action ta sendo testada, como vc fez nos outros describes. |
||
|
|
||
| it('teste para saber se o setTasks está retornando as tasks ', () => { | ||
|
|
||
| const expectedAction = { | ||
| type: "SET_TASK_DAY_ACTION", | ||
| payload: { | ||
| task: tasks | ||
| } | ||
| } | ||
|
|
||
| const actions = setTaskDayAction(tasks) | ||
|
|
||
| expect(actions).toEqual(expectedAction) | ||
| }); | ||
| }); | ||
|
|
||
| describe('teste do getTasks', () => { | ||
| it('teste para saber se o getTasks retorna um valor', async () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Também não precisa explicitar que é um teste. Procure colocar essa descricao do |
||
|
|
||
| const dispatchMock = jest.fn() | ||
|
|
||
| axios.get = jest.fn(() => { | ||
| return { | ||
| data: tasks | ||
| } | ||
| }) | ||
|
|
||
|
|
||
| await getTasks()(dispatchMock) | ||
|
|
||
| expect(dispatchMock).toHaveBeenCalledWith(setTaskDayAction(tasks)) | ||
| }); | ||
| }); | ||
|
|
||
| describe('testando se o CreateTask cria uma task', () => { | ||
| it('testando a função de criar tarefas', async () => { | ||
|
|
||
| const dispatchMock = jest.fn() | ||
| axios.post = jest.fn().mockReturnValue( { | ||
| status: 200 | ||
| }) | ||
|
|
||
| await createTask('ola', 'Segunda')(dispatchMock) | ||
|
|
||
| expect(dispatchMock).toHaveBeenCalled() | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from 'react'; | ||
| import { StyledHeader, PageName, TitleContainer } from '../../style/styled' | ||
|
|
||
|
|
||
| function Header () { | ||
| return ( | ||
| <StyledHeader> | ||
| <TitleContainer> | ||
| <PageName>W E E K </PageName> | ||
| <PageName>P L A N N E R</PageName> | ||
| </TitleContainer> | ||
| </StyledHeader> | ||
| ) | ||
| } | ||
|
|
||
| export default Header; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import React, { Fragment } from "react"; | ||
| import { Loading, Triangle } from "../../style/styled"; | ||
|
|
||
| function Loader ( ) { | ||
| return ( | ||
| <Fragment> | ||
| <svg width="150" height="150" viewBox="0 0 40 60"> | ||
| <Triangle | ||
| fill="none" | ||
| stroke="black" | ||
| stroke-width="1" | ||
| points="32,16 32,32 1,32 1,16" | ||
| /> | ||
| <Loading x="0" y="45" fill="black">Loading...</Loading> | ||
| </svg> | ||
| </Fragment> | ||
| ) | ||
| } | ||
|
|
||
| export default Loader; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import React from 'react'; | ||
| import { StyledSelect } from '../../style/styled' | ||
|
|
||
| export function SelectedDay (props) { | ||
| return ( | ||
| <StyledSelect name="day" value={props.value} onChange={props.onChange}> | ||
| <option value="" selected="selected">Change a day</option> | ||
| <option value="Segunda">Monday</option> | ||
| <option value="Terça">Tuesday</option> | ||
| <option value="Quarta">Wednesday</option> | ||
| <option value="Quinta">Thursday</option> | ||
| <option value="Sexta">Friday</option> | ||
| <option value="Sábado">Saturday</option> | ||
| <option value="Domingo">Sunday</option> | ||
| </StyledSelect> | ||
| ) | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from "react"; | ||
| import { TasksContainer, TasksContainerHeader, TasksContainerMain, StyledHr } from "../../style/styled" | ||
|
|
||
| export function TasksContainerComponent (props) { | ||
| return ( | ||
| <TasksContainer key={props.key}> | ||
| <TasksContainerHeader> | ||
| {props.day} | ||
| </TasksContainerHeader> | ||
| <StyledHr/> | ||
| <TasksContainerMain> | ||
| {props.text} | ||
| </TasksContainerMain> | ||
| </TasksContainer> | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identação