From 7e7dbb2648e76afbc81100d5291792c0de3a9b51 Mon Sep 17 00:00:00 2001 From: Vivelis Date: Thu, 23 Jul 2026 23:24:01 +0200 Subject: [PATCH 1/2] fix: deprecation warning --- app/(tabs)/__tests__/carte.test.tsx | 10 ++++++++++ app/(tabs)/carte.tsx | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/(tabs)/__tests__/carte.test.tsx diff --git a/app/(tabs)/__tests__/carte.test.tsx b/app/(tabs)/__tests__/carte.test.tsx new file mode 100644 index 0000000..91dea5e --- /dev/null +++ b/app/(tabs)/__tests__/carte.test.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { render } from '@testing-library/react-native'; +import CarteScreen from '../carte'; + +describe('CarteScreen', () => { + test('doit afficher correctement l\'écran de carte avec SafeAreaView de react-native-safe-area-context', () => { + const { getByTestId } = render(); + expect(getByTestId('map-view-container')).toBeTruthy(); + }); +}); diff --git a/app/(tabs)/carte.tsx b/app/(tabs)/carte.tsx index e2ce21b..93931df 100644 --- a/app/(tabs)/carte.tsx +++ b/app/(tabs)/carte.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { View, StyleSheet, SafeAreaView, Alert } from 'react-native'; +import { View, StyleSheet, Alert } from 'react-native'; +import { SafeAreaView } from 'react-native-safe-area-context'; import { colors, spacing } from '@/shared/constants/theme'; import { MapViewComponent, From abfa0843566a551c56e4a64f4b0b3d7867eaa4cb Mon Sep 17 00:00:00 2001 From: Vivelis Date: Thu, 23 Jul 2026 23:34:48 +0200 Subject: [PATCH 2/2] feat: add Ionicons to bottom navigation tabs and implement corresponding unit tests --- app/(tabs)/__tests__/_layout.test.tsx | 18 ++++++++++++++++++ app/(tabs)/_layout.tsx | 19 +++++++++++++++++++ jest.setup.js | 7 ++++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/(tabs)/__tests__/_layout.test.tsx diff --git a/app/(tabs)/__tests__/_layout.test.tsx b/app/(tabs)/__tests__/_layout.test.tsx new file mode 100644 index 0000000..38c88c4 --- /dev/null +++ b/app/(tabs)/__tests__/_layout.test.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { render } from '@testing-library/react-native'; +import TabLayout from '../_layout'; + +describe('TabLayout Navbar Icons', () => { + const tabs = ['index', 'activites', 'carte', 'finances', 'journal', 'profil']; + + tabs.forEach((tabName) => { + test(`doit définir un icon de navbar (tabBarIcon) pour la tab ${tabName}`, () => { + const { getByTestId } = render(); + const screenElement = getByTestId(`tab-screen-${tabName}`); + const options = screenElement.props.options; + + expect(options).toBeDefined(); + expect(typeof options.tabBarIcon).toBe('function'); + }); + }); +}); diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index 64e82c4..1e5cb75 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Tabs } from 'expo-router'; +import { Ionicons } from '@expo/vector-icons'; import { colors } from '@/shared/constants/theme'; export default function TabLayout() { @@ -21,6 +22,9 @@ export default function TabLayout() { options={{ title: 'Sorties', headerTitle: 'Mes Sorties', + tabBarIcon: ({ color, focused, size }) => ( + + ), }} /> ( + + ), }} /> ( + + ), }} /> ( + + ), }} /> ( + + ), }} /> ( + + ), }} /> diff --git a/jest.setup.js b/jest.setup.js index 579ebfb..783d06c 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1,4 +1,9 @@ // Mock Expo Router +const React = require('react'); +const MockTabs = ({ children }: any) => React.createElement('Tabs', null, children); +MockTabs.Screen = ({ name, options }: any) => + React.createElement('Tabs.Screen', { testID: `tab-screen-${name}`, name, options }); + jest.mock('expo-router', () => ({ useRouter: () => ({ push: jest.fn(), @@ -8,7 +13,7 @@ jest.mock('expo-router', () => ({ useSearchParams: () => ({}), usePathname: () => '/', Link: 'Link', - Tabs: 'Tabs', + Tabs: MockTabs, Stack: 'Stack', }));