2025-02-22 18:28:10 -08:00

35 lines
1.1 KiB
TypeScript

import {dirname, resolve} from 'path'
import React from 'react';
import { act, fireEvent, render, screen } from '@testing-library/react-native';
import { createStackNavigator } from '@react-navigation/stack';
jest.mock("@/app/i18n/api", () => require("../../__mocks__/api.ts"));
import TTNavStack from '../TTNavStack';
const Stack = createStackNavigator();
describe('Navigation', () => {
beforeEach(() => {
// Reset the navigation state before each test
jest.clearAllMocks();
});
it('Navigates to ConversationThread on language selection', async () => {
render(<TTNavStack />);
const languageSelectionText = await screen.findByText(/I Speak French\./i);
act(() => {
fireEvent.press(languageSelectionText);
})
expect(await screen.findByText("Conversation Thread")).toBeOnTheScreen();
});
it('Navigates to Settings on settings selection', async () => {
render(<TTNavStack />);
const settingsButton = await screen.findByText("Settings");
act(() => {
fireEvent.press(settingsButton)
})
expect(await screen.findByText("Settings")).toBeOnTheScreen();
});
});