Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { Constants, WebBrowser } from 'expo';
- import { View, Text } from 'react-native';
- import config from '../config';
- const AboutScreen = () => {
- const { termsAndConditionsUrl, privacyPolicyUrl } = config;
- const { releaseChannel, version } = Constants.manifest;
- const channel = (releaseChannel === undefined) ? 'DEV' : releaseChannel;
- return (
- <View>
- <Text>Version: {version}, Release-channel: {channel}</Text>
- <Text testId={"t-and-c"} onPress={() => WebBrowser.openBrowserAsync(termsAndConditionsUrl)}>
- Terms & conditions
- </Text>
- </View>
- );
- };
- export default AboutScreen;
- import React from 'react';
- import { shallow } from 'enzyme';
- import config from '../../config';
- import AboutScreen from '../AboutScreen';
- import { Constants, WebBrowser } from 'expo';
- const { termsAndConditionsUrl, privacyPolicyUrl } = config;
- jest.mock('expo', () => ({
- Constants:{
- manifest: {
- version: '0.0.1',
- releaseChannel: 'PROD',
- }},
- }));
- it('renders with releaseChannel and version', () => {
- const wrapper = shallow(<AboutScreen />);
- expect(wrapper).toMatchSnapshot();
- expect(wrapper).toContain('PROD');
- expect(wrapper).toContain('0.0.1');
- });
- jest.mock('expo', () => ({
- Constants:{
- manifest: {
- version: '0.0.2',
- }},
- }));
- it('renders with default releaseChannel', () => {
- const wrapper = shallow(<AboutScreen />);
- expect(wrapper).toMatchSnapshot();
- expect(wrapper).toContain('DEV');
- expect(wrapper).toContain('0.0.2');
- });
- jest.mock('expo');
- import * as expo from 'expo';
- expo.mockReturnValueOnce(); //but fails here as expo has no mockReturnValueOnce
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement