forked from fga-eps-mds/2023-2-GEROcuidado-Front
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from fga-eps-mds/feat/add-sync-between-watermel…
…on-and-backend Adiciona sincronização com a nuvem para Usuários e adiciona dados de Idoso, Rotina e Métricas offline
- Loading branch information
Showing
38 changed files
with
1,867 additions
and
774 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
EXPO_PUBLIC_API_URL=http://18.231.115.8 | ||
EXPO_PUBLIC_API_USUARIO_PORT=80 | ||
EXPO_PUBLIC_API_FORUM_PORT=80 | ||
EXPO_PUBLIC_API_SAUDE_PORT=80 | ||
EXPO_PUBLIC_API_URL=http://10.0.2.2 | ||
EXPO_PUBLIC_API_USUARIO_PORT=3001 | ||
EXPO_PUBLIC_API_FORUM_PORT=3002 | ||
EXPO_PUBLIC_API_SAUDE_PORT=3003 | ||
EXPO_PUBLIC_JWT_TOKEN_SECRET=f57d8cc37a35a8051aa97b5ec8506a2ac479e81f82aed9de975a0cb90b903044 |
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
Large diffs are not rendered by default.
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,41 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, screen, waitFor } from '@testing-library/react-native'; | ||
import FiltroDropdown from '../components/FiltroDropdown'; // ajuste o caminho conforme necessário | ||
|
||
describe('FiltroDropdown Component', () => { | ||
it('should render the dropdown with default label', () => { | ||
render(<FiltroDropdown filtro={null} setFiltro={() => {}} />); | ||
expect(screen.getByText('Filtro')).toBeTruthy(); | ||
}); | ||
|
||
it('should display options when dropdown is clicked', () => { | ||
render(<FiltroDropdown filtro={null} setFiltro={() => {}} />); | ||
const dropdownButton = screen.getByText('Filtro'); | ||
fireEvent.press(dropdownButton); | ||
|
||
expect(screen.getByText('Alimentação')).toBeTruthy(); | ||
expect(screen.getByText('Exercícios')).toBeTruthy(); | ||
expect(screen.getByText('Medicamentos')).toBeTruthy(); | ||
expect(screen.getByText('Geral')).toBeTruthy(); | ||
}); | ||
|
||
|
||
it('should toggle dropdown visibility when dropdown button is clicked', () => { | ||
render(<FiltroDropdown filtro={null} setFiltro={() => {}} />); | ||
|
||
const dropdownButton = screen.getByText('Filtro'); | ||
fireEvent.press(dropdownButton); | ||
|
||
expect(screen.getByText('Alimentação')).toBeTruthy(); | ||
|
||
fireEvent.press(dropdownButton); | ||
|
||
expect(screen.queryByText('Alimentação')).toBeNull(); | ||
}); | ||
|
||
it('should show selected option when a filter is provided', () => { | ||
render(<FiltroDropdown filtro="Alimentação" setFiltro={() => {}} />); | ||
expect(screen.getByText('Alimentação')).toBeTruthy(); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, screen } from '@testing-library/react-native'; | ||
import ModalMeta from '../components/ModalMeta'; | ||
import { EMetricas, IMetrica } from '../interfaces/metricas.interface'; | ||
|
||
describe('ModalMeta Component', () => { | ||
const mockCallbackFn = jest.fn(); | ||
const mockCloseModal = jest.fn(); | ||
|
||
const metrica: IMetrica = { | ||
id: 1, | ||
idIdoso: 1, | ||
categoria: EMetricas.HIDRATACAO, | ||
valorMaximo: '1000', | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should render modal when visible prop is true', () => { | ||
render( | ||
<ModalMeta | ||
visible={true} | ||
callbackFn={mockCallbackFn} | ||
closeModal={mockCloseModal} | ||
metrica={metrica} | ||
message="Test message" | ||
/> | ||
); | ||
|
||
expect(screen.getByText('Adicionar uma nova meta')).toBeTruthy(); | ||
}); | ||
|
||
it('should not render modal when visible prop is false', () => { | ||
render( | ||
<ModalMeta | ||
visible={false} | ||
callbackFn={mockCallbackFn} | ||
closeModal={mockCloseModal} | ||
metrica={metrica} | ||
message="Test message" | ||
/> | ||
); | ||
|
||
expect(screen.queryByText('Adicionar uma nova meta')).toBeNull(); | ||
}); | ||
|
||
it('should show error message when input is empty and Save button is pressed', () => { | ||
render( | ||
<ModalMeta | ||
visible={true} | ||
callbackFn={mockCallbackFn} | ||
closeModal={mockCloseModal} | ||
metrica={metrica} | ||
message="Test message" | ||
/> | ||
); | ||
|
||
fireEvent.press(screen.getByTestId('callbackBtn')); | ||
|
||
expect(screen.getByText('Campo obrigatório!')).toBeTruthy(); | ||
}); | ||
|
||
it('should show error message when input is invalid format and Save button is pressed', () => { | ||
render( | ||
<ModalMeta | ||
visible={true} | ||
callbackFn={mockCallbackFn} | ||
closeModal={mockCloseModal} | ||
metrica={metrica} | ||
message="Test message" | ||
/> | ||
); | ||
|
||
fireEvent.changeText(screen.getByTestId('modal-input'), 'invalid'); | ||
fireEvent.press(screen.getByTestId('callbackBtn')); | ||
|
||
expect(screen.getByText('Formato inválido!')).toBeTruthy(); | ||
}); | ||
|
||
it('should call callbackFn with input value when input is valid and Save button is pressed', () => { | ||
render( | ||
<ModalMeta | ||
visible={true} | ||
callbackFn={mockCallbackFn} | ||
closeModal={mockCloseModal} | ||
metrica={metrica} | ||
message="Test message" | ||
/> | ||
); | ||
|
||
fireEvent.changeText(screen.getByTestId('modal-input'), '100'); | ||
fireEvent.press(screen.getByTestId('callbackBtn')); | ||
|
||
expect(mockCallbackFn).toHaveBeenCalledWith('100'); | ||
}); | ||
|
||
it('should call closeModal when Cancel button is pressed', () => { | ||
render( | ||
<ModalMeta | ||
visible={true} | ||
callbackFn={mockCallbackFn} | ||
closeModal={mockCloseModal} | ||
metrica={metrica} | ||
message="Test message" | ||
/> | ||
); | ||
|
||
fireEvent.press(screen.getByTestId('cancelarBtn')); | ||
|
||
expect(mockCloseModal).toHaveBeenCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.