summaryrefslogtreecommitdiffstats
path: root/src/__tests__/navigation-test.tsx
blob: 4123ab7fe63f2d08acb1f36f2b08df717f8b2386 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { renderRouter, screen, fireEvent } from 'expo-router/testing-library';
import React from "react";
import { Text } from "react-native";

/**
 * Mock mínimo de las rutas reales
 * No renderiza toda la app, solo lo necesario
 */
describe("Navegación index → crearUsuario", () => {
  it("navega a la pantalla Crear Usuario al pulsar el botón", async () => {
    renderRouter(
      {
        index: require("../app/index").default,
        crearUsuario: require("../app/crearUsuario").default,
      },
      {
        initialUrl: "/",
      }
    );

    // Estamos en index
    expect(screen.getByText("crear usuario")).toBeTruthy();

    // Pulsamos el botón
    fireEvent.press(screen.getByTestId("btn-crear-usuario"));

    // Ahora debe renderizarse crearUsuario
    expect(
      await screen.findByText("Crear Usuario")
    ).toBeTruthy();
  });
});