Add test for AppInfoFooter

This commit is contained in:
Bill Thornton 2021-03-03 00:40:34 -05:00
parent d2e8a069f8
commit 8d0d6ba36e
3 changed files with 44 additions and 3 deletions

View File

@ -22,9 +22,15 @@ const AppInfoFooter = () => {
return (
<View style={styles.container}>
<Text style={textStyle}>{`${getAppName()}`}</Text>
<Text style={textStyle}>{`${Constants.nativeAppVersion} (${Constants.nativeBuildVersion})`}</Text>
<Text style={textStyle}>{t('settings.expoVersion', { version: Constants.expoVersion })}</Text>
<Text testID='app-name' style={textStyle}>
{`${getAppName()}`}
</Text>
<Text testID='app-version' style={textStyle}>
{`${Constants.nativeAppVersion} (${Constants.nativeBuildVersion})`}
</Text>
<Text testID='expo-version' style={textStyle}>
{t('settings.expoVersion', { version: Constants.expoVersion })}
</Text>
</View>
);
};

View File

@ -0,0 +1,30 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import * as Device from 'expo-device';
import Constants from 'expo-constants';
import React from 'react';
import { render } from '@testing-library/react-native';
import AppInfoFooter from '../AppInfoFooter';
import '../../i18n';
jest.mock('expo-constants');
jest.mock('expo-device');
describe('AppInfoFooter', () => {
it('should render correctly', () => {
Constants.expoVersion = '39.0.0';
Constants.nativeAppVersion = '1.0.0';
Constants.nativeBuildVersion = '1.0.0.0';
Device.osName = 'Test OS'; // eslint-disable-line no-import-assign, import/namespace
const { getByTestId } = render(<AppInfoFooter />);
expect(getByTestId('app-name')).toHaveTextContent('Jellyfin Mobile (Test OS)');
expect(getByTestId('app-version')).toHaveTextContent('1.0.0 (1.0.0.0)');
expect(getByTestId('expo-version')).toHaveTextContent('Expo Version: 39.0.0');
});
});

View File

@ -13,6 +13,9 @@
"setupFiles": [
"./jest.setup.js"
],
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.{js,jsx}",
@ -67,6 +70,8 @@
"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/eslint-parser": "^7.12.1",
"@testing-library/jest-native": "^4.0.0",
"@testing-library/react-native": "^7.2.0",
"@types/jest": "^26.0.20",
"@typescript-eslint/parser": "^4.9.1",
"babel-preset-expo": "^8.3.0",