Skip to content

Commit

Permalink
fix: app js fix
Browse files Browse the repository at this point in the history
  • Loading branch information
m-erkam committed Dec 16, 2024
1 parent e0b6ce5 commit 882d37e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 55 deletions.
9 changes: 4 additions & 5 deletions mobile/__tests__/CreatePost.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import { render, fireEvent, waitFor } from '@testing-library/react-native';
import CreatePost from '../src/pages/CreatePost'; // Adjust the import as necessary
import { useAuth } from '../src/hooks/useAuth'; // Adjust the import path as necessary
import CreatePost from '../src/pages/CreatePost';
import { useAuth } from '../src/hooks/useAuth';

// Mock useAuth hook
jest.mock('../src/hooks/useAuth', () => ({
useAuth: () => ({
accessToken: 'mockAccessToken', // Provide a default or mock value
accessToken: 'mockAccessToken',
userId: 'mockUserId',
}),
}));
Expand All @@ -18,7 +17,7 @@ describe('CreatePost Component', () => {
it('toggles tag selection', () => {
const { getByText, getByTestId } = render(<CreatePost />);

const tagChip = getByText('Tech'); // Assuming 'Tech' is the text of the tag chip
const tagChip = getByText('Tech');
fireEvent.press(tagChip);

expect(getByText("Tech").props.style.backgroundColor).toBe("#007BFF");
Expand Down
2 changes: 1 addition & 1 deletion mobile/__tests__/Post.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { render, waitFor, fireEvent } from '@testing-library/react-native';
import Post from '../src/pages/Post'; // Adjust the import as necessary
import Post from '../src/pages/Post';

jest.mock('node-fetch', () => require('jest-fetch-mock'));

Expand Down
2 changes: 1 addition & 1 deletion mobile/__tests__/Profile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import renderer from 'react-test-renderer';
import Profile from '../src/pages/ProfilePage';

// Mock the useAuth hook

jest.mock('../src/pages/context/AuthContext', () => ({
useAuth: () => ({
username: 'testuser',
Expand Down
56 changes: 8 additions & 48 deletions mobile/src/pages/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import Community from './Community';
import Post from './Post';
import CreatePost from './CreatePost';
import StockDetails from './StockDetails';
import Portfolio from './Portfolio';
import PortfolioDetails from './PortfolioDetails';
import CreatePortfolio from './CreatePortfolio';

import { AuthProvider, useAuth } from './context/AuthContext';

Expand Down Expand Up @@ -92,31 +89,6 @@ const MarketsStack = () => (
</Stack.Navigator>
);

const PortfolioStack = () => (
<Stack.Navigator>
<Stack.Screen
name="Markets1"
component={Portfolio}
options={{ header: ({ navigation }) => <CustomHeader navigation={navigation} /> }}
/>
<Stack.Screen
name="StockDetails"
component={StockDetails}
options={{ headerShown: true, title: 'Stock Details' }}
/>
<Stack.Screen
name="PortfolioDetails"
component={PortfolioDetails}
options={{ headerShown: true, title: 'Portfolio Details' }}
/>
<Stack.Screen
name="CreatePortfolio"
component={CreatePortfolio}
options={{ headerShown: true, title: 'Create Portfolio' }}
/>
</Stack.Navigator>
);

const DrawerNavigator = () => {
const { username, userId } = useAuth();

Expand All @@ -130,6 +102,11 @@ const DrawerNavigator = () => {
}}

>
<Drawer.Screen
name="Community"
component={PostStack}
options={{ headerShown: false }}
/>
<Drawer.Screen
name="Home"
component={Home}
Expand All @@ -154,29 +131,12 @@ const DrawerNavigator = () => {
options={{ headerShown: false }}

/>
<Drawer.Screen
name="Community"
component={PostStack}
options={{ headerShown: false }}
/>

<Drawer.Screen
name="News"
component={News}

/>
{ userId ? (
<Drawer.Screen
name="Portfolio"
component={PortfolioStack}
options={{ headerShown: false }}

/>
) : (
<Drawer.Screen
name="Portfolio"
component={LoginStack}
options={{ headerShown: false }}
/>
)}

</Drawer.Navigator>
);
Expand All @@ -198,7 +158,7 @@ const App = () => {
const styles = StyleSheet.create({
customHeader: {
height: 60,
backgroundColor: '#007BFF',
backgroundColor: '#0077B6',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
Expand Down

0 comments on commit 882d37e

Please sign in to comment.