Skip to content
Snippets Groups Projects
App-test.js 1.81 KiB
Newer Older
  • Learn to ignore specific revisions
  • zshan2's avatar
    zshan2 committed
    import 'react-native';
    import React from 'react';
    import Profile from '../Components/Profile';
    import App from '../App'
    import renderer from 'react-test-renderer';
    import Loading from '../Components/Loading';
    import Repo from '../Components/Repo';
    import { createStackNavigator } from '@react-navigation/stack';
    
    zshan2's avatar
    zshan2 committed
    import { NavigationContainer } from '@react-navigation/native';
    import Unfound from '../Components/Unfound';
    
    zshan2's avatar
    zshan2 committed
    
    const Stack = createStackNavigator();
    
    
    zshan2's avatar
    zshan2 committed
    test('renders correctly', () => {
    
    zshan2's avatar
    zshan2 committed
        const tree = renderer.create(
          <Loading />
        ).toJSON();
        expect(tree).toMatchSnapshot();
    
    zshan2's avatar
    zshan2 committed
      });
    
      test('renders correctly', ({navigation}) => {
        const dataFile = {
          iconUrl: "https://avatars.githubusercontent.com/u/42978932?u=b4a7beb2752bb6059cd13d12ca26d097767abf77&v=4",
          nameContent: null,
          userNameContent: null,
          bioContent: null,
          websiteLink: null,
          emailContent: null,
          createData: null,
          repoCount: 0,
          navi: navigation
        }
        const tree = renderer.create(
          <Profile data={dataFile}/>
        ).toJSON();
        expect(tree).toMatchSnapshot();
      });
    
      test('renders correctly', ({navigation}) => {
        const dataFile = {
          iconUrl: "https://avatars.githubusercontent.com/u/42978932?u=b4a7beb2752bb6059cd13d12ca26d097767abf77&v=4",
          nameContent: null,
          userNameContent: null,
          bioContent: null,
          websiteLink: null,
          emailContent: null,
          createData: null,
          repoCount: 0,
          navi: navigation
        }
        const tree = renderer.create(
          <Repo data={dataFile}/>
        ).toJSON();
        expect(tree).toMatchSnapshot();
      });
    
      test('renders correctly', ({navigation}) => {
        const dataFile = {
          navi: navigation
        }
        const tree = renderer.create(
          <Unfound data={dataFile}/>
        ).toJSON();
        expect(tree).toMatchSnapshot();
    
    zshan2's avatar
    zshan2 committed
      });