Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pruebas reasignar pacientes #67

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
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
38 changes: 38 additions & 0 deletions components/__tests__/TransferPatient.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import TransferPatient from '../../app/(app)/(root)/TransferPatient';
import { SessionContext } from '@/shared/LoginSession';
import { render, screen, fireEvent } from '@testing-library/react-native';


// Prueba de renderizado
it('renders TransferPatient component correctly', () => {
render(
<SessionContext.Provider value={{ docId: 'current-id' }}>
<TransferPatient />
</SessionContext.Provider>
);

expect(screen.getByText('Selecionar Pacientes A Transferir')).toBeTruthy();
expect(screen.getByPlaceholderText('Paciente')).toBeTruthy();
expect(screen.getByText('Transferir pacientes')).toBeTruthy();
});

// Prueba de búsqueda
it('filters patients based on search input', () => {
render(
<SessionContext.Provider value={{ docId: 'current-id' }}>
<TransferPatient />
</SessionContext.Provider>
);

// Verificar que ambos pacientes están inicialmente en la lista
expect(screen.getByText('Doe, Juan')).toBeTruthy();
expect(screen.getByText('Smith, Jane')).toBeTruthy();

// Simular entrada de búsqueda
fireEvent.changeText(screen.getByPlaceholderText('Paciente'), 'Jane');

// Verificar que solo el paciente que coincide con la búsqueda está en la lista
expect(screen.queryByText('Doe, Juan')).toBeNull();
expect(screen.getByText('Smith, Jane')).toBeTruthy();
});
35 changes: 35 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// jest.setup.js
import { jest } from '@jest/globals';

jest.mock('expo-router', () => ({
useRouter: jest.fn().mockReturnValue({ back: jest.fn() }),
useGlobalSearchParams: jest.fn().mockReturnValue({ targetProfessionalId: 'target-id' }),
}));

jest.mock('@/components/FetchData', () => ({
usePatientsFirestoreQuery: jest.fn().mockReturnValue({
data: [
{ idNumber: '12345678', firstName: 'Juan', lastName: 'Doe' },
{ idNumber: '87654321', firstName: 'Jane', lastName: 'Smith' }
],
error: null,
isLoading: false,
}),
}));

jest.mock('@react-native-firebase/firestore', () => ({
collection: jest.fn().mockReturnThis(),
doc: jest.fn().mockReturnThis(),
get: jest.fn().mockResolvedValue({ data: jest.fn() }),
set: jest.fn(),
delete: jest.fn(),
}));

jest.mock('react-native-flash-message', () => ({
showMessage: jest.fn(),
}));

jest.mock('react-native-vector-icons/Ionicons', () => 'Icon');
jest.mock('@/assets/images/greenCheckIcon.png', () => 'greenCheckIcon');
jest.mock('@/assets/images/redCheckIcon.png', () => 'redCheckIcon');
jest.mock('@/assets/images/searchIcon.png', () => 'searchIcon');
160 changes: 159 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
"preset": "jest-expo",
"setupFiles": ["./jest.setup.js"],
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
]
},
"dependencies": {
"@expo/vector-icons": "^14.0.0",
Expand Down Expand Up @@ -61,6 +65,9 @@
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^12.5.1",
"@types/jest": "^29.5.12",
"@types/react": "~18.2.45",
"@types/react-native-vector-icons": "^6.4.18",
"@types/uuid": "^9.0.8",
Expand Down