Skip to content

Commit

Permalink
Merge pull request #24 from Capstone-Projects-2021-Fall/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
tuj39467 committed Oct 18, 2021
2 parents b333f31 + bf58c7f commit 060c941
Show file tree
Hide file tree
Showing 21 changed files with 21,245 additions and 255 deletions.
12 changes: 4 additions & 8 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import { SafeAreaProvider } from "react-native-safe-area-context";
import Navigation from "./navigation/index";
import useCachedResources from "./hooks/useCachedResources";
import useColorScheme from "./hooks/useColorScheme";
import { AuthProvider } from "./context/FirebaseAuthProvider";
import CatMap from "./components/CatMap";

import Navigation from "./navigation/index";
import { CatForm2 } from "./CatForm2";
import CatForm from "./screens/CatForm";

export default function App() {
const isLoadingComplete = useCachedResources();
Expand All @@ -16,13 +16,9 @@ export default function App() {
return (
<SafeAreaProvider>
<AuthProvider>
<Navigation colorScheme={colorScheme} />
<Navigation colorScheme={colorScheme} />
</AuthProvider>
</SafeAreaProvider>
);
}
}




200 changes: 200 additions & 0 deletions CatForm2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import React, { useState } from "react";
import { Button, CheckBox } from "react-native-elements";
import { Picker } from "@react-native-picker/picker";
import "react-native-get-random-values";
import { v4 as uuidv4 } from "uuid";
import { Cat, Pin } from "./types";
import { addCat, addPin } from "./utils/dbInterface";
import { LatLng } from "react-native-maps";
import LocationPicker from "./screens/LocationPicker";
import {
Modal,
TextInput,
SafeAreaView,
StyleSheet,
ScrollView,
} from "react-native";
import CatImagePicker from "./components/ImagePicker";
import Camera from "./components/Camera";

export const CatForm2 = () => {
const colors = ["Set Cat Color", "Orange", "Brown", "Black", "White"];
const eyeColors = [
"Set Cat Eye Color",
"Brown",
"Green",
"Blue",
"Black",
"Yellow",
"Orange",
"Hazel",
"Mixed",
];

const [color, setColor] = useState();
const [eyeColor, setEyeColor] = useState();
const [friendly, setFriendly] = useState(false);
const [healthy, setHealthy] = useState(false);
const [kitten, setKitten] = useState(false);
const [locationModalVisible, setLocationModalVisible] = useState(false);
const [camModalVisible, setCamModalVisible] = useState(false);

const [cat, setCat]: Cat = useState({
catID: uuidv4(),
comments: "",
name: "",
color: "",
eyeColor: "",
media: "",
friendly: false,
healthy: false,
kitten: false,
pinID: uuidv4(),
});

const [pin, setPin]: Pin = useState({
pinID: cat.pinID,
location: "",
time: new Date(),
votes: 0,
accountID: "",
type: cat.catID,
});

function onLocationPick(coordinate: LatLng) {
setPin((currentState) => ({
...currentState,
location: coordinate,
}));
setLocationModalVisible(false);
}

return (
<SafeAreaView>
<ScrollView>
<TextInput
value={cat.name}
selectionColor="white"
placeholder="Enter possible name here"
placeholderTextColor="black"
onChangeText={(text) =>
setCat((currentState) => ({
...currentState,
name: text,
}))
}
style={styles.input}
/>
<TextInput
style={styles.input}
selectionColor="white"
placeholder="Enter additional information here"
placeholderTextColor="black"
value={cat.comments}
onChangeText={(text) =>
setCat((currentState) => ({
...currentState,
comments: text,
}))
}
/>
<CheckBox
title="Friendly?"
checked={friendly}
onPress={() => {
setFriendly(!friendly);
cat.friendly = !cat.friendly;
}}
/>
<CheckBox
title="Healthy?"
checked={healthy}
onPress={() => {
setHealthy(!healthy);
cat.healthy = !cat.healthy;
}}
/>
<CheckBox
title="Kitten?"
checked={kitten}
onPress={() => {
setKitten(!kitten);
cat.kitten = !cat.kitten;
}}
/>
<Picker
style={{ backgroundColor: "white" }}
selectedValue={color}
onValueChange={(item) => {
setColor(item);
cat.color = colors[item];
}}
>
{colors.map((item, index) => {
return <Picker.Item label={item} value={index} key={index} />;
})}
</Picker>
<Picker
style={{ backgroundColor: "white" }}
selectedValue={eyeColor}
onValueChange={(item) => {
setEyeColor(item);
cat.eyeColor = eyeColors[item];
}}
>
{eyeColors.map((item, index) => {
return <Picker.Item label={item} value={index} key={index} />;
})}
</Picker>

<CatImagePicker />

{/* <Button title="Open Camera" onPress={() => setCamModalVisible(true)} />
<Modal
animationType="slide"
onRequestClose={() => setCamModalVisible(!camModalVisible)}
transparent={true}
visible={camModalVisible}
>
<Camera />
</Modal> */}
<Button
title="add location"
color="#2126F3"
onPress={() => setLocationModalVisible(true)}
/>

<Button
title="submit cat"
onPress={() => {
addCat(cat);
addPin(pin);
alert("Cat submitted reload app");
return;
}}
/>

<Modal animationType="slide" visible={locationModalVisible}>
<LocationPicker
onCancel={() => {
setLocationModalVisible(false);
}}
onConfirm={onLocationPick}
/>
</Modal>
</ScrollView>
</SafeAreaView>
);
};

const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
padding: 10,
color: "black",
backgroundColor: "white",
},
});
16 changes: 16 additions & 0 deletions __tests__/Account-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { render, fireEvent} from '@testing-library/react-native';
import Account from '../screens/Account';
import LoginAuthentication from '../components/LoginAuthentication';

import { RootTabScreenProps } from '../types';


it("renders default elements", () => {
render(<Account/>);
});

it("renders correct display element", () => {
const {getAllByText} = render(<Account/>);
expect(getAllByText('Account').length).toBe(1);
});
15 changes: 15 additions & 0 deletions __tests__/Announcement-Test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { render, fireEvent} from '@testing-library/react-native';
import ModalScreen from '../screens/AnnouncementsModal';

it("renders default elements", () => {
render(<ModalScreen/>);
});

it("renders correct display element", () => {
const {getAllByText} = render(<ModalScreen/>);
expect(getAllByText('Notifications are going to be built in here').length).toBe(1);
});



39 changes: 39 additions & 0 deletions __tests__/CatForm-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { render, fireEvent} from '@testing-library/react-native';
import Navigation from "../navigation/index";
import CatForm from "../screens/CatForm";
import { Alert } from 'react-native';



//Check to make sure it has all the correct fields
//Check to make sure that the data is being uploaded
//Check that error message and activity returns when a field is not fully filled out


it("renders default elements", () => {
render(<CatForm/>);
});

//Add test id element to make it work

it('shows error message when all boxes are not filled out',() => {
jest.spyOn(Alert, 'alert');
const {getByTestId} = render(<CatForm/>);
fireEvent.press(getByTestId("Submit.Button"));
expect(Alert.alert).toHaveBeenCalledWith("Please fill out all required fields");

});


describe('Testing react navigation', () => {
test('renders the title of form', async () => {
const component = (
<CatForm />
);
const { findByText } = render(component);
const header = await findByText('Cat Form');
});

});
14 changes: 14 additions & 0 deletions __tests__/Leaderboard-Test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as React from 'react';
import { render, fireEvent} from '@testing-library/react-native';
import LeaderboardScreen from '../screens/Leaderboard';
import { RootTabScreenProps } from '../types';


it("renders default elements", () => {
render(<LeaderboardScreen/>);
});

it("renders correct display element", () => {
const {getAllByText} = render(<LeaderboardScreen/>);
expect(getAllByText('Leaderboard').length).toBe(1);
});
14 changes: 14 additions & 0 deletions __tests__/Resources-Test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as React from 'react';
import { render, fireEvent} from '@testing-library/react-native';
import ResourcesScreen from '../screens/Resources';
import { RootTabScreenProps } from '../types';


it("renders default elements", () => {
render(<ResourcesScreen/>);
});

it("renders correct display element", () => {
const {getAllByText} = render(<ResourcesScreen/>);
expect(getAllByText('Resources').length).toBe(1);
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import renderer from 'react-test-renderer';

import { MonoText } from '../StyledText';
import { MonoText } from '../components/StyledText';

it(`renders correctly`, () => {
const tree = renderer.create(<MonoText>Snapshot test!</MonoText>).toJSON();
Expand Down
21 changes: 21 additions & 0 deletions __tests__/__snapshots__/StyledText-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders correctly 1`] = `
<Text
style={
Array [
Object {
"color": "#000",
},
Array [
undefined,
Object {
"fontFamily": "space-mono",
},
],
]
}
>
Snapshot test!
</Text>
`;
Loading

0 comments on commit 060c941

Please sign in to comment.