Skip to content

Instantly share code, notes, and snippets.

@yanmendes
yanmendes / description.md
Last active May 25, 2020 15:24
Números por Extenso

Challenge Description

Fazer uma função que receba um número inteiro entre 0 e 999 e retorne uma string, que é esse número por extenso em português.

Baby steps: recomendamos que você comece pelos menores números e vá evoluindo o algoritmo até resolver os maiores.

A cada passo que der, tenha testes unitários mostrando o funcionamento, independentemente de estar usando um framework ou não.

{"lastUpload":"2020-05-22T23:30:13.144Z","extensionVersion":"v3.4.3"}
it('should print a success message and redirect on a successful submission', async () => {
const Routes = () =>
<>
<Route path='/' exact component={App} />
<Route path='/success' exact component={Success} />
</>
const {
getByLabelText,
getByText,
const renderWithReduxAndRouter = (
routes,
{
initialState = {},
store = createStore(reducer, initialState, applyMiddleware(thunk))
} = {},
{
route = '/',
history = createMemoryHistory({ initialEntries: [route] })
} = {}
it('should print an error message in a failed submission', async () => {
axios.post.mockRejectedValue('not ok :(')
const { getByLabelText, getByText, findByText } = renderWithRedux(<App />)
const password = '123456'
const email = 'foo@bar.com'
fireEvent.input(getByLabelText('Email'), setValue(email))
fireEvent.input(getByLabelText('Password'), setValue(password))
const renderWithRedux = (
ui,
{
initialState = {},
store = createStore(reducer, initialState, applyMiddleware(thunk))
} = {}
) => ({
...render(<Provider store={store}>{ui}</Provider>),
store
})
it('should not submit an invalid form', () => {
const { getByText } = render(<App />)
fireEvent.click(getByText('Submit'))
expect(axios.post).not.toHaveBeenCalled()
})
import { render, fireEvent } from '@testing-library/react'
test('should submit a valid form', () => {
const { getByLabelText, getByText } = render(<App />)
const setValue = value => ({ target: { value } })
const password = '123456'
const email = 'foo@bar.com'
fireEvent.input(getByLabelText('Email'), setValue(email))
fireEvent.input(getByLabelText('Password'), setValue(password))
// src/setupTests.js
import '@testing-library/react/cleanup-after-each'
import '@testing-library/jest-dom/extend-expect'
// src/App.test.js
import axios from 'axios'
jest.mock('axios')
axios.post.mockResolvedValue('ok!')
docker exec -it bigdawg-postgres-catalog bash
psql
\c bigdawg_schemas
CREATE TABLE port (id integer, direction integer);