//@ts-nocheck import React from 'react'; import { render } from '@testing-library/react-native'; import Text from '../../Text'; import { NativeBaseProvider } from '../../../../core/NativeBaseProvider'; import { theme as defaultTheme } from '../../../../theme'; jest.useFakeTimers(); const theme = { ...defaultTheme, fontConfig: { Roboto: { 100: 'Roboto-Light', 200: 'Roboto-Light', 300: 'Roboto-Light', 400: { normal: 'Roboto-Regular', italic: 'Roboto-Italic', }, 500: 'Roboto-Medium', 600: 'Roboto-Medium', 700: { normal: 'Roboto-Bold', italic: 'Roboto-BoldItalic', }, 800: 'Roboto-Bold', 900: 'Roboto-Black', }, }, fonts: { ...defaultTheme.fonts, heading: 'Roboto', body: 'Roboto', }, }; const Provider = (props: any) => { return ( ); }; describe('Text component', () => { it('resolves default custom fonts', () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe('Roboto-Regular'); }); it('resolves custom font variants', () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe('Roboto-Italic'); }); it('resolves to bold italic font', () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe('Roboto-BoldItalic'); }); it('resolves to medium font when fontWeight is 500', () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe('Roboto-Medium'); }); it('resolves to medium font when fontWeight is medium', () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe('Roboto-Medium'); }); it('respects fontFamily property', () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe('Merriweather-Italic'); }); it("doesn't break if custom font is not specified", () => { let newTheme = JSON.parse(JSON.stringify(defaultTheme)); delete newTheme.fontConfig; let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontFamily).toBe(undefined); }); it("doesn't pass fontWeight and fontStyle if a custom fontFamily is resolved", () => { let { getByTestId } = render( hello world ); let text = getByTestId('my-text'); expect(text.props.style.fontWeight).toBe(undefined); expect(text.props.style.fontStyle).toBe(undefined); expect(text.props.style.fontFamily).toBe('Roboto-Regular'); }); });