-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Capstone-Projects-2021-Fall/staging
Staging
- Loading branch information
Showing
21 changed files
with
21,245 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
2 changes: 1 addition & 1 deletion
2
components/__tests__/StyledText-test.js → __tests__/StyledText-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; |
Oops, something went wrong.