Skip to content
Merged
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
18 changes: 18 additions & 0 deletions app/(tabs)/__tests__/_layout.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<TabLayout />);
const screenElement = getByTestId(`tab-screen-${tabName}`);
const options = screenElement.props.options;

expect(options).toBeDefined();
expect(typeof options.tabBarIcon).toBe('function');
});
});
});
10 changes: 10 additions & 0 deletions app/(tabs)/__tests__/carte.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<CarteScreen />);
expect(getByTestId('map-view-container')).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -21,41 +22,59 @@ export default function TabLayout() {
options={{
title: 'Sorties',
headerTitle: 'Mes Sorties',
tabBarIcon: ({ color, focused, size }) => (
<Ionicons name={focused ? 'calendar' : 'calendar-outline'} size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="activites"
options={{
title: 'Activités',
headerTitle: 'Découvrir',
tabBarIcon: ({ color, focused, size }) => (
<Ionicons name={focused ? 'sparkles' : 'sparkles-outline'} size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="carte"
options={{
title: 'Carte',
headerTitle: 'Carte & Explorer',
tabBarIcon: ({ color, focused, size }) => (
<Ionicons name={focused ? 'map' : 'map-outline'} size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="finances"
options={{
title: 'Finances',
headerTitle: 'Dépenses du groupe',
tabBarIcon: ({ color, focused, size }) => (
<Ionicons name={focused ? 'wallet' : 'wallet-outline'} size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="journal"
options={{
title: 'Journal',
headerTitle: "Journal d'aventure",
tabBarIcon: ({ color, focused, size }) => (
<Ionicons name={focused ? 'book' : 'book-outline'} size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="profil"
options={{
title: 'Profil',
headerTitle: 'Mon Profil',
tabBarIcon: ({ color, focused, size }) => (
<Ionicons name={focused ? 'person' : 'person-outline'} size={size} color={color} />
),
}}
/>
</Tabs>
Expand Down
3 changes: 2 additions & 1 deletion app/(tabs)/carte.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 6 additions & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -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(),
Expand All @@ -8,7 +13,7 @@ jest.mock('expo-router', () => ({
useSearchParams: () => ({}),
usePathname: () => '/',
Link: 'Link',
Tabs: 'Tabs',
Tabs: MockTabs,
Stack: 'Stack',
}));

Expand Down
Loading