From 7809ccbba56be8c5377f94cf2d287a0e1521fdc1 Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Wed, 25 Mar 2026 15:32:20 +0000 Subject: Initial commit: App Oficina base project --- src/__tests__/navigation-test.tsx | 32 +++++++++++++++++ src/app/GuardarPersona.tsx | 34 ++++++++++++++++++ src/app/GuardarProducto.tsx | 61 +++++++++++++++++++++++++++++++++ src/app/_layout.tsx | 58 +++++++++++++++++++++++++++++++ src/app/index.tsx | 39 +++++++++++++++++++++ src/context/AppContextProvider.tsx | 39 +++++++++++++++++++++ src/db/schema.ts | 43 +++++++++++++++++++++++ src/images/android-icon-background.png | Bin 0 -> 17549 bytes src/images/android-icon-foreground.png | Bin 0 -> 78796 bytes src/images/android-icon-monochrome.png | Bin 0 -> 4140 bytes src/images/favicon.png | Bin 0 -> 1129 bytes src/images/icon.png | Bin 0 -> 393493 bytes src/images/partial-react-logo.png | Bin 0 -> 5075 bytes src/images/react-logo.png | Bin 0 -> 6341 bytes src/images/react-logo@2x.png | Bin 0 -> 14225 bytes src/images/react-logo@3x.png | Bin 0 -> 21252 bytes src/images/splash-icon.png | Bin 0 -> 17547 bytes 17 files changed, 306 insertions(+) create mode 100644 src/__tests__/navigation-test.tsx create mode 100644 src/app/GuardarPersona.tsx create mode 100644 src/app/GuardarProducto.tsx create mode 100644 src/app/_layout.tsx create mode 100644 src/app/index.tsx create mode 100644 src/context/AppContextProvider.tsx create mode 100644 src/db/schema.ts create mode 100644 src/images/android-icon-background.png create mode 100644 src/images/android-icon-foreground.png create mode 100644 src/images/android-icon-monochrome.png create mode 100644 src/images/favicon.png create mode 100644 src/images/icon.png create mode 100644 src/images/partial-react-logo.png create mode 100644 src/images/react-logo.png create mode 100644 src/images/react-logo@2x.png create mode 100644 src/images/react-logo@3x.png create mode 100644 src/images/splash-icon.png (limited to 'src') diff --git a/src/__tests__/navigation-test.tsx b/src/__tests__/navigation-test.tsx new file mode 100644 index 0000000..4123ab7 --- /dev/null +++ b/src/__tests__/navigation-test.tsx @@ -0,0 +1,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(); + }); +}); diff --git a/src/app/GuardarPersona.tsx b/src/app/GuardarPersona.tsx new file mode 100644 index 0000000..58b1d2d --- /dev/null +++ b/src/app/GuardarPersona.tsx @@ -0,0 +1,34 @@ +import { StyleSheet, Text, View, Button} from 'react-native' +import React from 'react' +import { useSQLiteContext } from 'expo-sqlite'; +import { drizzle, useLiveQuery } from 'drizzle-orm/expo-sqlite'; +import { personas } from '../db/schema'; +import { SafeAreaView } from 'react-native-safe-area-context'; + + +const GuardarPersona = () => { + const db = useSQLiteContext(); + const drizzleDb = drizzle(db, { schema: { personas } }); + const { data: lista } = useLiveQuery(drizzleDb.select().from(personas)); + async function almacenarPersona(){ + let edadAleatoria = Math.trunc(Math.random()*100); + let nombreAleatorio = "persona_"+Math.trunc(Math.random()*10000); + await drizzleDb.insert(personas).values({ nombre: nombreAleatorio, edad: edadAleatoria }); + } + + return ( + + Guardar Persona +