Skip to content

Commit

Permalink
test: adding data base mock in listarIdosos file test
Browse files Browse the repository at this point in the history
  • Loading branch information
GustaaSZ committed Sep 18, 2024
1 parent 224243e commit fe55b65
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/app/__tests__/listarIdosos.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@ jest.mock('expo-router', () => ({
}),
}));

// Mockando o módulo dos serviços para substituir as implementações
jest.mock("../services/idoso.service");
// Mockando o banco de dados e a função getIdosos
jest.mock("../db/index", () => ({
get: jest.fn().mockReturnValue({
query: jest.fn().mockReturnValue({
fetch: jest.fn().mockResolvedValueOnce([
{ _raw: { id: 1, nome: "Idoso 1", foto: "foto1.jpg" } },
{ _raw: { id: 2, nome: "Idoso 2", foto: "foto2.jpg" } },
]),
}),
}),
}));

jest.mock("@react-native-async-storage/async-storage", () => ({
getItem: jest.fn(),
}));

describe("ListarIdosos", () => {

Expand Down

0 comments on commit fe55b65

Please sign in to comment.