Skip to content

Commit

Permalink
Merge pull request #49 from fga-eps-mds/feature/##199-ativar-notificacao
Browse files Browse the repository at this point in the history
[#199] ativar notificacao
  • Loading branch information
pedro-cella authored Dec 6, 2023
2 parents 9864419 + ac4f5e2 commit 2d050ac
Show file tree
Hide file tree
Showing 16 changed files with 810 additions and 465 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ yarn-error.*
*.tsbuildinfo

/coverage

ios

android
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
},
"owner": "gerocuidado"
}
}
}
532 changes: 493 additions & 39 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
"expo-jwt": "^1.6.5",
"expo-linking": "~5.0.2",
"expo-router": "^2.0.4",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"expo-updates": "~0.18.17",
"jest": "^29.2.1",
"jest-expo": "^49.0.0",
"jest-mock-extended": "^3.0.5",
"jest-sonar": "^0.2.16",
"jest-sonar-reporter": "^2.0.0",
"native-notify": "^3.2.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.6",
Expand All @@ -50,7 +52,9 @@
"react-native-toast-message": "^2.1.7",
"react-native-vector-icons": "^10.0.0",
"react-native-web": "~0.19.6",
"ts-jest": "^29.1.1"
"ts-jest": "^29.1.1",
"expo-device": "~5.4.0",
"expo-notifications": "~0.20.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down Expand Up @@ -95,4 +99,4 @@
]
]
}
}
}
237 changes: 131 additions & 106 deletions src/app/__tests__/CadastrarRotina.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,111 +1,136 @@
import React from 'react';
import { render, fireEvent, waitFor, act } from '@testing-library/react-native';
import CadastrarRotina from '../private/pages/cadastrarRotina';


describe('CadastrarRotina Component', () => {
it('Salvar sem titulo', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const titulo = getByPlaceholderText('Adicionar título');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(titulo, '');
fireEvent.press(salvar);
});
const erroTitulo = getByTestId('Erro-titulo');

expect(erroTitulo.props.children.props.text).toBe('Campo obrigatório!');
import React from "react";
import { render, fireEvent, waitFor, act } from "@testing-library/react-native";
import CadastrarRotina from "../private/pages/cadastrarRotina";

describe("CadastrarRotina Component", () => {
it("Salvar sem titulo", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const titulo = getByPlaceholderText("Adicionar título");
const salvar = getByText("Salvar");

act(() => {
fireEvent.changeText(titulo, "");
fireEvent.press(salvar);
});
const erroTitulo = getByTestId("Erro-titulo");

expect(erroTitulo.props.children.props.text).toBe("Campo obrigatório!");
});

it("Salvar com titulo muito grande", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const titulo = getByPlaceholderText("Adicionar título");
const salvar = getByText("Salvar");

act(() => {
fireEvent.changeText(
titulo,
"Por que o livro de matemática está sempre triste? Porque tem muitos problemas! hahahahahahhahahahahhahahaahahahahahahhahahahahahahahahahahahhahaahahahahahahahahah",
);
fireEvent.press(salvar);
});
const erroTitulo = getByText("O título deve ter no máximo 100 caracteres.");

expect(erroTitulo).toBeTruthy();
});

it("Salvar sem data", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const data = getByPlaceholderText("Data da rotina");
const salvar = getByText("Salvar");

act(() => {
fireEvent.changeText(data, "");
fireEvent.press(salvar);
});
const erroData = getByTestId("Erro-data");

expect(erroData.props.children.props.text).toBe("Campo obrigatório");
});

it("Salvar data com formato errado", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const data = getByPlaceholderText("Data da rotina");
const salvar = getByText("Salvar");

act(() => {
fireEvent.changeText(data, "2010");
fireEvent.press(salvar);
});
const erroData = getByTestId("Erro-data");

expect(erroData.props.children.props.text).toBe(
"Data deve ser no formato dd/mm/yyyy!",
);
});

it("Salvar sem hora", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const hora = getByPlaceholderText("Horário de início");
const salvar = getByText("Salvar");

act(() => {
fireEvent.changeText(hora, "");
fireEvent.press(salvar);
});
const erroHora = getByTestId("Erro-hora");

expect(erroHora.props.children.props.text).toBe("Campo obrigatório");
});

it("Salvar hora com formato errado", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const hora = getByPlaceholderText("Horário de início");
const salvar = getByText("Salvar");

act(() => {
fireEvent.changeText(hora, "201");
fireEvent.press(salvar);
});
const erroHora = getByTestId("Erro-hora");

expect(erroHora.props.children.props.text).toBe(
"Hora deve ser no formato hh:mm!",
);
});

it("Salvar com descrição muito grande", async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(
<CadastrarRotina />,
);

const descricao = getByPlaceholderText("Descrição");
const salvar = getByText("Salvar");

it('Salvar com titulo muito grande', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const titulo = getByPlaceholderText('Adicionar título');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(titulo, 'Por que o livro de matemática está sempre triste? Porque tem muitos problemas! hahahahahahhahahahahhahahaahahahahahahhahahahahahahahahahahahhahaahahahahahahahahah');
fireEvent.press(salvar);
});
const erroTitulo = getByText('O título deve ter no máximo 100 caracteres.');

expect(erroTitulo).toBeTruthy();
act(() => {
fireEvent.changeText(
descricao,
"Chapeuzinho Vermelho, uma garotinha de capa vermelha, foi mandada pela mãe para levar doces à vovó doente. No caminho, encontrou o lobo, que a enganou perguntando sobre o destino. O lobo, mais rápido, chegou à casa da vovó primeiro, a engoliu e se disfarçou. Quando Chapeuzinho chegou, notou algo estranho na vovó. O lobo tentou enganá-la, mas Chapeuzinho percebeu. O caçador apareceu, salvou-as, cortou a barriga do lobo, libertando vovó e Chapeuzinho. Moral: cuidado com estranhos, até mesmo disfarçados de vovó!",
);
fireEvent.press(salvar);
});
const erroDescricao = getByTestId("Erro-descricao");

it('Salvar sem data', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const data = getByPlaceholderText('Data da rotina');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(data, '');
fireEvent.press(salvar);
});
const erroData = getByTestId('Erro-data');

expect(erroData.props.children.props.text).toBe('Campo obrigatório');
});

it('Salvar data com formato errado', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const data = getByPlaceholderText('Data da rotina');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(data, '2010');
fireEvent.press(salvar);
});
const erroData = getByTestId('Erro-data');

expect(erroData.props.children.props.text).toBe('Data deve ser no formato dd/mm/yyyy!');
});

it('Salvar sem hora', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const hora = getByPlaceholderText('Horário de início');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(hora, '');
fireEvent.press(salvar);
});
const erroHora = getByTestId('Erro-hora');

expect(erroHora.props.children.props.text).toBe('Campo obrigatório');
});

it('Salvar hora com formato errado', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const hora = getByPlaceholderText('Horário de início');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(hora, '201');
fireEvent.press(salvar);
});
const erroHora = getByTestId('Erro-hora');

expect(erroHora.props.children.props.text).toBe('Hora deve ser no formato hh:mm!');
});

it('Salvar com descrição muito grande', async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<CadastrarRotina />);

const descricao = getByPlaceholderText('Descrição');
const salvar = getByText('Salvar');

act(() => {
fireEvent.changeText(descricao, 'Chapeuzinho Vermelho, uma garotinha de capa vermelha, foi mandada pela mãe para levar doces à vovó doente. No caminho, encontrou o lobo, que a enganou perguntando sobre o destino. O lobo, mais rápido, chegou à casa da vovó primeiro, a engoliu e se disfarçou. Quando Chapeuzinho chegou, notou algo estranho na vovó. O lobo tentou enganá-la, mas Chapeuzinho percebeu. O caçador apareceu, salvou-as, cortou a barriga do lobo, libertando vovó e Chapeuzinho. Moral: cuidado com estranhos, até mesmo disfarçados de vovó!');
fireEvent.press(salvar);
});
const erroDescricao = getByTestId('Erro-descricao');

expect(erroDescricao.props.children.props.text).toBe('A descrição deve ter no máximo 300 caracteres.');
});
expect(erroDescricao.props.children.props.text).toBe(
"A descrição deve ter no máximo 300 caracteres.",
);
});
});
Loading

0 comments on commit 2d050ac

Please sign in to comment.