Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CanciuCostin committed Sep 9, 2024
1 parent e3754a3 commit 031fda6
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 207 deletions.
154 changes: 77 additions & 77 deletions src/__tests__/integration/IntegrationTests.ts
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
const env = process.env
const env = process.env;

describe('Properties File Tests', () => {
it('should have EXPO_PUBLIC_BACKEND_URL defined', () => {
expect(env.EXPO_PUBLIC_BACKEND_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_BACKEND_URL defined', () => {
expect(env.EXPO_PUBLIC_BACKEND_URL).toBeDefined();
});

it('should have EXPO_PUBLIC_STRIPE_PAYMENT_URL defined', () => {
expect(env.EXPO_PUBLIC_STRIPE_PAYMENT_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_STRIPE_PAYMENT_URL defined', () => {
expect(env.EXPO_PUBLIC_STRIPE_PAYMENT_URL).toBeDefined();
});

it('should have EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY defined', () => {
expect(env.EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY).toBeDefined();
});
it('should have EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY defined', () => {
expect(env.EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY).toBeDefined();
});

it('should have EXPO_PUBLIC_PRODUCTS_ENDPOINT defined', () => {
expect(env.EXPO_PUBLIC_PRODUCTS_ENDPOINT).toBeDefined();
});
it('should have EXPO_PUBLIC_PRODUCTS_ENDPOINT defined', () => {
expect(env.EXPO_PUBLIC_PRODUCTS_ENDPOINT).toBeDefined();
});

it('should have EXPO_PUBLIC_TAGS_ENDPOINT defined', () => {
expect(env.EXPO_PUBLIC_TAGS_ENDPOINT).toBeDefined();
});
it('should have EXPO_PUBLIC_TAGS_ENDPOINT defined', () => {
expect(env.EXPO_PUBLIC_TAGS_ENDPOINT).toBeDefined();
});

it('should have EXPO_PUBLIC_CATEGORIES_ENDPOINT defined', () => {
expect(env.EXPO_PUBLIC_CATEGORIES_ENDPOINT).toBeDefined();
});
it('should have EXPO_PUBLIC_CATEGORIES_ENDPOINT defined', () => {
expect(env.EXPO_PUBLIC_CATEGORIES_ENDPOINT).toBeDefined();
});

it('should have EXPO_PUBLIC_VIDEO_PREVIEW_URL defined', () => {
expect(env.EXPO_PUBLIC_VIDEO_PREVIEW_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_VIDEO_PREVIEW_URL defined', () => {
expect(env.EXPO_PUBLIC_VIDEO_PREVIEW_URL).toBeDefined();
});

it('should have EXPO_PUBLIC_RATE_APP_URL_ANDROID defined', () => {
expect(env.EXPO_PUBLIC_RATE_APP_URL_ANDROID).toBeDefined();
});
it('should have EXPO_PUBLIC_RATE_APP_URL_ANDROID defined', () => {
expect(env.EXPO_PUBLIC_RATE_APP_URL_ANDROID).toBeDefined();
});

it('should have EXPO_PUBLIC_RATE_APP_URL_IOS defined', () => {
expect(env.EXPO_PUBLIC_RATE_APP_URL_IOS).toBeDefined();
});
it('should have EXPO_PUBLIC_RATE_APP_URL_IOS defined', () => {
expect(env.EXPO_PUBLIC_RATE_APP_URL_IOS).toBeDefined();
});

it('should have EXPO_PUBLIC_CONTACT_URL defined', () => {
expect(env.EXPO_PUBLIC_CONTACT_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_CONTACT_URL defined', () => {
expect(env.EXPO_PUBLIC_CONTACT_URL).toBeDefined();
});

it('should have EXPO_PUBLIC_TERMS_URL defined', () => {
expect(env.EXPO_PUBLIC_TERMS_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_TERMS_URL defined', () => {
expect(env.EXPO_PUBLIC_TERMS_URL).toBeDefined();
});

it('should have EXPO_PUBLIC_PRIVACY_URL defined', () => {
expect(env.EXPO_PUBLIC_PRIVACY_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_PRIVACY_URL defined', () => {
expect(env.EXPO_PUBLIC_PRIVACY_URL).toBeDefined();
});

it('should have EXPO_PUBLIC_ABOUT_URL defined', () => {
expect(env.EXPO_PUBLIC_ABOUT_URL).toBeDefined();
});
it('should have EXPO_PUBLIC_ABOUT_URL defined', () => {
expect(env.EXPO_PUBLIC_ABOUT_URL).toBeDefined();
});
});

describe('Integration Tests', () => {
test('Products Endpoint', async () => {
if(!env.EXPO_PUBLIC_BACKEND_URL?.includes('10.0.2.2')) {
const response = await fetch(env.EXPO_PUBLIC_BACKEND_URL || '');
expect(response.status).toBe(200);
}
});

test('Payments Endpoint', async () => {
const response = await fetch(env.EXPO_PUBLIC_STRIPE_PAYMENT_URL!);
expect(response.status).toBe(200);
// Add more assertions for the response data if needed
});

test('Video Preview Endpoint', async () => {
const response = await fetch(env.EXPO_PUBLIC_VIDEO_PREVIEW_URL!);
expect(response.status).toBe(200);
// Add more assertions for the response data if needed
});

test('Terms URL', async () => {
const response = await fetch(env.EXPO_PUBLIC_TERMS_URL!);
expect([200,410]).toContain(response.status);
// Add more assertions for the response data if needed
});

test('Privacy URL', async () => {
const response = await fetch(env.EXPO_PUBLIC_PRIVACY_URL!);
expect([200,410]).toContain(response.status);
// Add more assertions for the response data if needed
});

test('About URL', async () => {
const response = await fetch(env.EXPO_PUBLIC_ABOUT_URL!);
expect([200,410]).toContain(response.status);
// Add more assertions for the response data if needed
});
});
test('Products Endpoint', async () => {
if (!env.EXPO_PUBLIC_BACKEND_URL?.includes('10.0.2.2')) {
const response = await fetch(env.EXPO_PUBLIC_BACKEND_URL || '');
expect(response.status).toBe(200);
}
});

test('Payments Endpoint', async () => {
const response = await fetch(env.EXPO_PUBLIC_STRIPE_PAYMENT_URL!);
expect(response.status).toBe(200);
// Add more assertions for the response data if needed
});

test('Video Preview Endpoint', async () => {
const response = await fetch(env.EXPO_PUBLIC_VIDEO_PREVIEW_URL!);
expect(response.status).toBe(200);
// Add more assertions for the response data if needed
});

test('Terms URL', async () => {
const response = await fetch(env.EXPO_PUBLIC_TERMS_URL!);
expect([200, 410]).toContain(response.status);
// Add more assertions for the response data if needed
});

test('Privacy URL', async () => {
const response = await fetch(env.EXPO_PUBLIC_PRIVACY_URL!);
expect([200, 410]).toContain(response.status);
// Add more assertions for the response data if needed
});

test('About URL', async () => {
const response = await fetch(env.EXPO_PUBLIC_ABOUT_URL!);
expect([200, 410]).toContain(response.status);
// Add more assertions for the response data if needed
});
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import {
View,
StyleSheet,
Image,
ScrollView,
Alert,
Animated,
} from 'react-native';
import { View, StyleSheet, Image, ScrollView, Alert } from 'react-native';
import ImagePicker from '@components/input/ImagePicker';
import DropDown from '@components/input/DropDown';
import DateTimePicker from '@components/input/DateTimePicker';
import CustomTextInput from '@components/input/CustomTextInput';
import { AppDispatch, persistor, RootState } from '@state/store';
import { AppDispatch, RootState } from '@state/store';
import { useDispatch, useSelector } from 'react-redux';
import ProductsHelper from '@helpers/ProductsHelper';
import {
Expand Down Expand Up @@ -257,8 +250,8 @@ export default function ProductOrderScreen() {
}

function validateForm(): Promise<void> {
console.log('Validating form');
return new Promise((resolve, reject) => {
// Uncomment to clear the persisted data
// persistor.purge().then(() => {
// resolve();
// });
Expand All @@ -270,7 +263,8 @@ export default function ProductOrderScreen() {
switch: termsApproved,
});
if (!isFormValid) {
console.log(errors);
//Uncomment to see the errors
//console.log(errors);
const scrollOffset = getScrollOffset();
if (scrollOffset === 0) {
scrollViewRef.current?.scrollToEnd({ animated: true });
Expand All @@ -293,7 +287,7 @@ export default function ProductOrderScreen() {
message: message,
image: image,
};
// TODO: Request to create order. Parse response
// TODO: Server request to create order. Parse response
const order: Order = {
orderId: Crypto.randomUUID(),
orderDate: new Date(Date.now()),
Expand Down Expand Up @@ -321,8 +315,9 @@ export default function ProductOrderScreen() {
.then(() => openPaymentSheet())
.then(() => saveOrder())
.catch((err) => {
console.log({ err });
}); //TODO: Handle error on order creation
//Uncomment to see the error
//console.log({ err });
});

return (
<View style={[styles.container]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import React from 'react';
import { AppDispatch, RootState } from '@state/store';
import { useDispatch, useSelector } from 'react-redux';
import PersonalizationDataCard from '@components/PersonalizationDataCard';
import { heightPercentageToDP as hp } from 'react-native-responsive-screen';
import CustomText from '@components/CustomText';
import { useTheme } from '@react-navigation/native';
import { router } from 'expo-router';
import Screens from '@constants/Screens';
import { setSelectedPersonalizationDataId } from '@state/productsDataSlice';
Expand All @@ -31,7 +29,6 @@ export default function PersonalizationDataList() {
(state: RootState) => state.productsData.personalizationData,
);

const { colors } = useTheme();
const dispatch = useDispatch<AppDispatch>();
const { t } = useTranslation();

Expand Down
3 changes: 2 additions & 1 deletion src/app/(tabs)/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export default function SettingsScreen() {
? (process.env.EXPO_PUBLIC_RATE_APP_URL_ANDROID as string)
: (process.env.EXPO_PUBLIC_RATE_APP_URL_IOS as string),
).catch((err) => {
console.error(err);
//Uncomment the line below to see the error in the console
//console.error(err);
})
}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DarkTheme, ThemeProvider } from '@react-navigation/native';
import { ThemeProvider } from '@react-navigation/native';
import { Stack } from 'expo-router';
import 'react-native-reanimated';
import { useColorScheme } from 'react-native';
Expand Down
3 changes: 2 additions & 1 deletion src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export default function SplashAnimation() {
Promise.all([
fetchProducts().then((response) =>
dispatch(setProductsAsync(response)).catch((error) => {
console.error('Error fetching products:', error);
//Uncomment the line below to see the error in the console
//console.error('Error fetching products:', error);
throw new Error(error);
}),
),
Expand Down
1 change: 0 additions & 1 deletion src/components/input/__tests__/CustomSwitch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import CustomSwitch from '@components/input/CustomSwitch';
import { screen } from '@testing-library/react-native';

describe('CustomSwitch', () => {
it('renders correctly with default props', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/input/__tests__/DropDown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import DropDown from '@components/input/DropDown';
import { screen } from '@testing-library/react-native';

describe('DropDown', () => {
const dropdownItems = ['Option 1', 'Option 2', 'Option 3'];
Expand Down
1 change: 0 additions & 1 deletion src/components/input/__tests__/LanguageSwitcher.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import LanguageSwitcher from '@components/input/LanguageSwitcher';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useTranslation } from 'react-i18next';

jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock'),
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/__tests__/SettingsDropDown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('SettingsDropDown Component', () => {
});

it('closes the modal when the close button is pressed', () => {
const { queryByTestId, getByTestId, getByText, queryByRole } = render(
const { queryByTestId, getByTestId, getByText } = render(
<SettingsDropDown dropdownItems={dropdownItems} label={label} />,
);

Expand Down
3 changes: 2 additions & 1 deletion src/constants/Screens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export default {
categoriesListPath: '/categories',
categoriesDetailsPath: '/categories/[categoryId]',
productDetailsPath: '/categories/[categoryId]/products/[productId]',
productOrderPath: '/categories/[categoryId]/products/[productId]/productOrder',
productOrderPath:
'/categories/[categoryId]/products/[productId]/productOrder',
ordersListPath: '/orders',
personalizationDataPath: '/categories/[categoryId]/products/personalization',
};
6 changes: 3 additions & 3 deletions src/constants/Strings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
WHITESPACE_CHARACTER: ' ',
MANDATORY_CHARACTER: '*',
}
WHITESPACE_CHARACTER: ' ',
MANDATORY_CHARACTER: '*',
};
24 changes: 12 additions & 12 deletions src/data/SupportedLanguages.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { SupportedLanguage } from "@models/Languages";
import { SupportedLanguage } from '@models/Languages';

const SUPPORTED_LANGUAGES: SupportedLanguage[] = [
{
name: "English",
code: "en",
flagIsoCode: "GB",
},
{
name: "Romana",
code: "ro",
flagIsoCode: "RO",
},
{
name: 'English',
code: 'en',
flagIsoCode: 'GB',
},
{
name: 'Romana',
code: 'ro',
flagIsoCode: 'RO',
},
];

export default SUPPORTED_LANGUAGES;
export default SUPPORTED_LANGUAGES;
15 changes: 9 additions & 6 deletions src/helpers/DateFormatHelper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import AsyncStorage from '@react-native-async-storage/async-storage';

export default function formatDateByLocale(date: Date): Promise<string> {
return AsyncStorage.getItem('user-language').then((language) =>
date.toLocaleDateString(language || 'en', {
year: 'numeric',
month: 'long',
day: 'numeric',
}).toLocaleUpperCase());
return AsyncStorage.getItem('user-language').then((language) =>
date
.toLocaleDateString(language || 'en', {
year: 'numeric',
month: 'long',
day: 'numeric',
})
.toLocaleUpperCase(),
);
}
2 changes: 1 addition & 1 deletion src/helpers/ProductsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class ProductsHelper {
categoryId: string | undefined,
categories: Category[],
): string => {
if(categoryId === undefined) return '';
if (categoryId === undefined) return '';
return (
categories.find((category) => category.categoryId === categoryId)
?.categoryName || ''
Expand Down
Loading

0 comments on commit 031fda6

Please sign in to comment.