daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { Constants, WebBrowser } from 'expo';
  3. import { View, Text } from 'react-native';
  4. import config from '../config';
  5.  
  6. const AboutScreen = () => {
  7. const { termsAndConditionsUrl, privacyPolicyUrl } = config;
  8. const { releaseChannel, version } = Constants.manifest;
  9. const channel = (releaseChannel === undefined) ? 'DEV' : releaseChannel;
  10. return (
  11.     <View>
  12.         <Text>Version: {version}, Release-channel: {channel}</Text>
  13.         <Text testId={"t-and-c"} onPress={() => WebBrowser.openBrowserAsync(termsAndConditionsUrl)}>
  14.     Terms & conditions
  15.         </Text>
  16.     </View>
  17.   );
  18. };
  19.  
  20.  
  21. export default AboutScreen;
  22.      
  23. import React from 'react';
  24.  import { shallow } from 'enzyme';
  25.  import config from '../../config';
  26.  import AboutScreen from '../AboutScreen';
  27.  import { Constants, WebBrowser } from 'expo';
  28.  const { termsAndConditionsUrl, privacyPolicyUrl } = config;
  29.  
  30.   jest.mock('expo', () => ({
  31.    Constants:{
  32.      manifest: {
  33.        version: '0.0.1',
  34.        releaseChannel: 'PROD',
  35.     }},
  36.   }));
  37.  
  38.   it('renders with releaseChannel and version', () => {
  39.     const wrapper = shallow(<AboutScreen />);
  40.     expect(wrapper).toMatchSnapshot();
  41.     expect(wrapper).toContain('PROD');
  42.     expect(wrapper).toContain('0.0.1');
  43.   });
  44.  
  45.   jest.mock('expo', () => ({
  46.    Constants:{
  47.      manifest: {
  48.        version: '0.0.2',
  49.     }},
  50.   }));
  51.  
  52.   it('renders with default releaseChannel', () => {
  53.     const wrapper = shallow(<AboutScreen />);
  54.     expect(wrapper).toMatchSnapshot();
  55.     expect(wrapper).toContain('DEV');
  56.     expect(wrapper).toContain('0.0.2');
  57.    });
  58.      
  59. jest.mock('expo');
  60. import * as expo from 'expo';
  61. expo.mockReturnValueOnce(); //but fails here as expo has no mockReturnValueOnce
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top