Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/.gitignore
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*
14,494 changes: 14,494 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/package-lock.json

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/package.json
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"
]
}
44 changes: 44 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/public/index.html
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>
31 changes: 31 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/src/actions/index.js
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))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identação

}

export const createTask = (text, day) => async (dispatch) => {

const newTask = {
text,
day
}

const response = await axios.post(`${baseUrl}`, newTask)

if(response.status === 200) {

dispatch(getTasks())
}
}
57 changes: 57 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/src/actions/index.test.js
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', () => {
Copy link

Choose a reason for hiding this comment

The 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 () => {
Copy link

Choose a reason for hiding this comment

The 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 it no seguinte formato: "deve retornar um valor". E o describe seria só "getTasks". Então, o describe define o que está sendo testado, e o it define o que exatamente cada teste testa.


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()
});
});
16 changes: 16 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/src/components/Header/index.js
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;
20 changes: 20 additions & 0 deletions semana12/Aula3-Projeto-WeekPlanner/src/components/Loader/index.js
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>
)
}
Loading