Skip to content

Commit

Permalink
Merge pull request #80 from Capstone-Projects-2021-Fall/TEM-146
Browse files Browse the repository at this point in the history
Tem 146
  • Loading branch information
rebeccarobb committed Nov 28, 2021
2 parents 616941a + ad001af commit f616c8e
Show file tree
Hide file tree
Showing 9 changed files with 3,032 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "temple-cats"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ npm-debug.*
*.orig.*
web-build/
docs/
ui-debug.log
firebase-debug.log
database-debug.log

# macOS
.DS_Store
202 changes: 151 additions & 51 deletions __tests__/dbInterface-test.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,164 @@
import React from 'react';
import { addUser } from '../utils/dbInterface';
import firebase from '../utils/firebase';


jest.mock('../utils/firebase', () => {
const set = jest.fn();
return {
database: jest.fn(() => ({
ref: jest.fn(() => ({
child: jest.fn(() => ({
set,
})),
})),
})),
};
});
import firebase from 'firebase';
import "firebase/database";

const firebaseConfig = {
apiKey: "AIzaSyDhKqRV1ALg80TdK0GsSFEq0BR6BK8UiPs",
authDomain: "temple-cats.firebaseapp.com",
databaseURL: "http://localhost:9000/?ns=temple-cats",
projectId: "temple-cats",
storageBucket: "temple-cats.appspot.com",
messagingSenderId: "645364453008",
appId: "1:645364453008:web:e2b6afd21de03516ccd215",
measurementId: "G-PTQHR7RT4M",
ssl: false
};

firebase.initializeApp(firebaseConfig);
const dbRef = firebase.database().ref();

describe('Add User', () => {
describe('DB Interface', () => {

beforeAll(() => {
dbRef.set(null);
})

it('Adds a cat', async () => {
const set = dbRef
.child(`Cats/cat1`)
.set({
accountID: 'acc1',
catID: 'cat1',
color: 'White',
date: '11/9/2021',
eyeColor: 'Green',
friendly: false,
healthy: false,
kitten: false,
location: {latitude: 39.98446100629369, longitude: -75.15069779008627},
media: 'TODO',
name: 'Test Cat',
time: '9:23:00 AM',
votes: 0
});
await expect(set).resolves.toEqual(undefined);
});

it('Gets cats', async () => {
const get = await dbRef
.child('Cats')
.get()
expect(get.exists()).toBeTruthy();
expect(get.hasChildren()).toBeTruthy();
expect(get.numChildren() == 1).toBeTruthy();
expect(get.child('cat1').val().color).toEqual('White');
});

it('Changes votes of a cat', async () => {
const votes = await dbRef
.child('Cats/cat1/votes')
.get();
const set = dbRef
.child('Cats/cat1/votes')
.set(votes.val() + 1);
expect(set).resolves.toEqual(undefined);
});

it('Adds report to a cat', async () => {
expect(1).toEqual(1);
});

it('Gets reports of a cat', async () => {
expect(1).toEqual(1);
});

it('Removes reports of a cat', async () => {
expect(1).toEqual(1);
});

it('Adds a comment to a cat', async () => {
expect(1).toEqual(1);
});

it('Gets a cat\'s comments', async () => {
expect(1).toEqual(1);
});

it('Adds report to a cat\'s comment', async () => {
expect(1).toEqual(1);
});

it('Gets reports of a cat\'s comment', async () => {
expect(1).toEqual(1);
});

it('Removes report on a cat\'s comment', async () => {
expect(1).toEqual(1);
});

it('Removes a cat\'s comment', async () => {
expect(1).toEqual(1);
});

it('Removes a cat', async () => {
const remove = dbRef
.child('Cats/cat1')
.remove();
expect(remove).resolves.toEqual(undefined);
});

it('Gets feeding stations', async () => {
expect(1).toEqual(1);
});

it('Adds a user', async () => {
const set = firebase
.database()
.ref()
.child(`Accounts/krs8Lf6EXbb9GTBmQlaj4nvx1CA2`)
const set = dbRef
.child(`Accounts/acc1`)
.set({
display: 'Jordan Billie',
accountID: 'krs8Lf6EXbb9GTBmQlaj4nvx1CA2',
accountID: 'acc1',
email: 'bjthaniel3@hotmail.com',
photo: 'https://graph.facebook.com/2544322639045275/picture',
posts: 0,
modStatus: 1,
banStatus: false,
});


const result = addUser(
'Jordan Billie',
'krs8Lf6EXbb9GTBmQlaj4nvx1CA2',
'bjthaniel3@hotmail.com',
'https://graph.facebook.com/2544322639045275/picture'
);
});
await expect(set).resolves.toEqual(undefined);
});


await expect(result).resolves.toEqual("true");

//expect(set).toHaveBeenCalledTimes(1);
it('Gets users', async () => {
expect(1).toEqual(1);
});


// expect(set).toHaveBeenCalledWith({
// courseId: 'THE_ROAD_TO_GRAPHQL',
// packageId: 'STUDENT',
// invoice: {
// createdAt: 'TIMESTAMP',
// amount: 0,
// licensesCount: 1,
// currency: 'USD',
// paymentType: 'FREE',
// },
// });

});

it('Changes a user\'s score', async () => {
expect(1).toEqual(1);
});

it('Removes a user', async () => {
expect(1).toEqual(1);
});

it('Adds an announcement', async () => {
expect(1).toEqual(1);
});

it('Gets announcements', async () => {
expect(1).toEqual(1);
});

it('Removes an announcement', async () => {
expect(1).toEqual(1);
});

it('Uploads a cat\'s picture', async () => {
expect(1).toEqual(1);
});

it('Gets a cat\'s picture', async () => {
expect(1).toEqual(1);
});

it('Deletes a cat\'s picture', async () => {
expect(1).toEqual(1);
});
});

5 changes: 0 additions & 5 deletions components/Mod.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import * as React from 'react';
import * as WebBrowser from 'expo-web-browser';
import * as Facebook from 'expo-auth-session/providers/facebook';
import { ResponseType } from 'expo-auth-session';
import { Button } from 'react-native';
import firebase from '../utils/firebase';
import Navigation from '../navigation';

export default function Mod(props: {
onReportedPostsPress: () => void;
Expand Down
6 changes: 6 additions & 0 deletions database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
".read": true,
".write": true,
}
}
22 changes: 22 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"database": {
"rules": "database.rules.json"
},
"storage": {
"rules": "storage.rules"
},
"emulators": {
"auth": {
"port": 9099
},
"database": {
"port": 9000
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
}
}
}
Loading

0 comments on commit f616c8e

Please sign in to comment.