Skip to content
Snippets Groups Projects
Commit dbea22c9 authored by zshan2's avatar zshan2
Browse files

final commit

parent 0406e34c
No related branches found
No related tags found
1 merge request!1<Assignment-3.0>
...@@ -6,6 +6,7 @@ import Loading from './Components/Loading' ...@@ -6,6 +6,7 @@ import Loading from './Components/Loading'
import Profile from './Components/Profile' import Profile from './Components/Profile'
import Repo from './Components/Repo' import Repo from './Components/Repo'
import Unfound from './Components/Unfound' import Unfound from './Components/Unfound'
import DataGenerator from './Components/DataGenerator'
const Stack = createStackNavigator(); const Stack = createStackNavigator();
const styles = StyleSheet.create({ const styles = StyleSheet.create({
...@@ -19,23 +20,7 @@ const styles = StyleSheet.create({ ...@@ -19,23 +20,7 @@ const styles = StyleSheet.create({
marginHorizontal: 10, paddingVertical:10, paddingHorizontal: 50, alignItems: 'flex-start'} marginHorizontal: 10, paddingVertical:10, paddingHorizontal: 50, alignItems: 'flex-start'}
}); });
/** Home page **/ function generateData(route, navigation) {
function HomeScreen({ navigation }) {
return (
<View style={styles.container}>
<ImageBackground source={require('C:/Coding/cs242-assignment3/GitView/assets/ice.jpg')} style={styles.image}>
<View style={styles.viewStyleVertical}>
<Pressable style={styles.pressableStyle} onPress={() => navigation.navigate('LoadingProfile')}>
<Text> Start </Text>
</Pressable>
</View>
</ImageBackground>
</View>
);
}
/** Profile page **/
function ProfileScreen({ route, navigation }) {
const {name, login, avatarUrl, bio, createdAt, email, websiteUrl, repositories} = route.params; const {name, login, avatarUrl, bio, createdAt, email, websiteUrl, repositories} = route.params;
const dataFile = {} const dataFile = {}
dataFile['navi'] = navigation dataFile['navi'] = navigation
...@@ -46,7 +31,6 @@ function ProfileScreen({ route, navigation }) { ...@@ -46,7 +31,6 @@ function ProfileScreen({ route, navigation }) {
dataFile['emailContent'] = 'Email: \n' + email dataFile['emailContent'] = 'Email: \n' + email
dataFile['websiteLink'] = 'Website: \n' + websiteUrl dataFile['websiteLink'] = 'Website: \n' + websiteUrl
dataFile['repoCount'] = 'Repository count: ' + repositories['nodes'].length dataFile['repoCount'] = 'Repository count: ' + repositories['nodes'].length
console.log(avatarUrl)
var iconUrl var iconUrl
if (avatarUrl != null) { if (avatarUrl != null) {
iconUrl = { uri: avatarUrl } iconUrl = { uri: avatarUrl }
...@@ -54,6 +38,28 @@ function ProfileScreen({ route, navigation }) { ...@@ -54,6 +38,28 @@ function ProfileScreen({ route, navigation }) {
iconUrl = require('C:/Coding/cs242-assignment3/GitView/assets/default.png') iconUrl = require('C:/Coding/cs242-assignment3/GitView/assets/default.png')
} }
dataFile['iconUrl'] = iconUrl dataFile['iconUrl'] = iconUrl
return dataFile
}
/** Home page **/
function HomeScreen({ navigation }) {
return (
<View style={styles.container}>
<ImageBackground source={require('C:/Coding/cs242-assignment3/GitView/assets/ice.jpg')} style={styles.image}>
<View style={styles.viewStyleVertical}>
<Pressable style={styles.pressableStyle} onPress={() => navigation.navigate('LoadingProfile')}>
<Text> Start </Text>
</Pressable>
</View>
</ImageBackground>
</View>
);
}
/** Profile page **/
function ProfileScreen({ route, navigation }) {
var dataFile = generateData(route, navigation)
return ( return (
<Profile data={dataFile}/> <Profile data={dataFile}/>
); );
......
function generateData(route, navigation) {
const {name, login, avatarUrl, bio, createdAt, email, websiteUrl, repositories} = route.params;
const dataFile = {}
dataFile['navi'] = navigation
dataFile['nameContent'] = 'Name: \n' + name
dataFile['userNameContent'] = 'UserName\n: ' + login
dataFile['bioContent'] = 'Bio: \n' + bio
dataFile['createDate'] = 'Create at: \n' + createdAt
dataFile['emailContent'] = 'Email: \n' + email
dataFile['websiteLink'] = 'Website: \n' + websiteUrl
dataFile['repoCount'] = 'Repository count: ' + repositories['nodes'].length
var iconUrl
if (avatarUrl != null) {
iconUrl = { uri: avatarUrl }
} else {
iconUrl = require('C:/Coding/cs242-assignment3/GitView/assets/default.png')
}
dataFile['iconUrl'] = iconUrl
return dataFile
}
module.exports = generateData;
\ No newline at end of file
...@@ -6,23 +6,60 @@ import renderer from 'react-test-renderer'; ...@@ -6,23 +6,60 @@ import renderer from 'react-test-renderer';
import Loading from '../Components/Loading'; import Loading from '../Components/Loading';
import Repo from '../Components/Repo'; import Repo from '../Components/Repo';
import { createStackNavigator } from '@react-navigation/stack'; import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import Unfound from '../Components/Unfound';
const Stack = createStackNavigator(); const Stack = createStackNavigator();
test('renders correctly', ({}) => { test('renders correctly', () => {
// 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,
// navigation: navigation
// }
const tree = renderer.create( const tree = renderer.create(
<Loading /> <Loading />
).toJSON(); ).toJSON();
expect(tree).toMatchSnapshot(); 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(
<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();
}); });
\ No newline at end of file
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';
import { NavigationContainer } from '@react-navigation/native';
import Unfound from '../Components/Unfound';
const Stack = createStackNavigator();
const generateData = require()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment