-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
5,322 additions
and
22,444 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"plugin:jsx-a11y/recommended", | ||
"next/core-web-vitals", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
] | ||
} |
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
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,5 @@ | ||
.github/ | ||
*.config.js | ||
.prettierrc.js | ||
*.md | ||
settings.json |
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import type { StorybookConfig } from "@storybook/nextjs"; | ||
import type { StorybookConfig } from '@storybook/nextjs'; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
"../stories/**/*.mdx", | ||
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)", | ||
'../stories/**/*.mdx', | ||
'../components/**/*.stories.@(js|jsx|mjs|ts|tsx)', | ||
], | ||
staticDirs: ['../public'], | ||
addons: [ | ||
"@storybook/addon-onboarding", | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@chromatic-com/storybook", | ||
"@storybook/addon-interactions", | ||
'@storybook/addon-onboarding', | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@chromatic-com/storybook', | ||
'@storybook/addon-interactions', | ||
], | ||
framework: { | ||
name: "@storybook/nextjs", | ||
name: '@storybook/nextjs', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
autodocs: 'tag', | ||
}, | ||
}; | ||
export default config; |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# 👴Senior devs. Each PR requires at least 1 senior review before merging. | ||
* @shashilo @mhchen @jayrobin | ||
* @shashilo @mhchen |
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,114 @@ | ||
import { loginAccount, logoutAccount, registerAccount } from './apiFunctions'; | ||
import { account } from './config'; | ||
const apiFunctions = require("./apiFunctions"); | ||
|
||
jest.mock("./apiFunctions", ()=> { | ||
const actualModule = jest.requireActual("./apiFunctions"); | ||
return { | ||
...actualModule, | ||
createWeeklyPicks: jest.fn(), | ||
getUserWeeklyPick: jest.fn() | ||
} | ||
}) | ||
|
||
describe('Auth Functions', () => { | ||
jest.mock('./apiFunctions', () => ({ | ||
loginAccount: jest.fn(), | ||
registerAccount: jest.fn(), | ||
})); | ||
|
||
xdescribe('login account successful', () => { | ||
it('should show user login successfully', async () => { | ||
const userDummy = { | ||
email: '[email protected]', | ||
password: 'test1234', | ||
}; | ||
await loginAccount(userDummy); | ||
expect(account.createEmailPasswordSession).toBeInstanceOf(Object); | ||
}); | ||
|
||
//user failed to log in | ||
it('should send error if user could not log in', async () => { | ||
const failDummy = { | ||
email: '[email protected]', | ||
password: 'tet1234679', | ||
}; | ||
await loginAccount(failDummy); | ||
expect(loginAccount(failDummy)).rejects.toThrow('error'); | ||
}); | ||
}); | ||
|
||
// Test the logout function | ||
describe('logout account works', () => { | ||
it('should log out successfully', async () => { | ||
jest | ||
.spyOn(account, 'deleteSession') | ||
.mockResolvedValueOnce('Session deleted'); | ||
await logoutAccount(); | ||
expect(account.deleteSession).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
||
account.create = jest.fn(); | ||
describe('register account successful', () => { | ||
it('Should allow a user to register an account', async () => { | ||
const userDummy = { | ||
email: '[email protected]', | ||
password: 'test12345', | ||
}; | ||
const response = await registerAccount(userDummy); | ||
expect(account.create).toHaveBeenCalledWith( | ||
expect.any(String), | ||
userDummy.email, | ||
userDummy.password, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
xtest('get weekly picks mock function', async () => { | ||
const users = { userId: '66174f2362ec891167be' }; | ||
const resp = { data: users }; | ||
|
||
// Mocking the getWeeklyPicks function | ||
jest.mock('./apiFunctions', () => ({ | ||
getUserWeeklyPick: jest.fn().mockResolvedValue(resp), | ||
})); | ||
|
||
// Importing the mocked function | ||
const { getUserWeeklyPick: mockGetUserWeeklyPick } = require('./apiFunctions'); | ||
|
||
// Call the function | ||
const result = await mockGetUserWeeklyPick(); | ||
|
||
// Assertions | ||
expect(result).toEqual(resp); // Check if the result matches the expected response | ||
}); | ||
|
||
|
||
describe("Get Weekly Picks Mock function", () => { | ||
it('should mock getWeeklyPicks function', async () => { | ||
const users = {$id: '663130a100297f77c3c8' }; | ||
const resp = { data: users }; | ||
|
||
apiFunctions.getUserWeeklyPick.mockResolvedValue(resp); | ||
|
||
const result = await apiFunctions.getUserWeeklyPick({userId: '66281d5ec5614f76bc91', weekNumber: "6622c75658b8df4c4612"}); | ||
|
||
expect(result).toEqual(resp); | ||
}); | ||
}); | ||
|
||
describe("Create Weekly Picks Mock Function", () => { | ||
it("should mock createWeeklyPicks function", async () => { | ||
const users = { team: '66218f22b40deef340f8', correct: false }; | ||
const resp = {data: users}; | ||
|
||
apiFunctions.createWeeklyPicks.mockResolvedValue(resp); | ||
|
||
const result = await apiFunctions.createWeeklyPicks({gameWeekId: "6622c7596558b090872b",gameId: "66311a210039f0532044", userResults: "{\"66281d5ec5614f76bc91\":{\"team\":\"66218f22b40deef340f8\",\"correct\":false},\"6628077faeeedd272637\":{\"team\":\"6621b30ea57bd075e9d3\",\"correct\":false}, \"66174f2362ec891167be\":{\"team\": \"6621b30ea57bd075e9d3\", \"correct\":true}}"}); | ||
|
||
expect(result).toEqual(resp); | ||
|
||
}) | ||
}) |
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,85 @@ | ||
import { account, databases, ID, appwriteConfig } from './config'; | ||
|
||
export async function loginAccount(user: { email: string; password: string }) { | ||
try { | ||
return await account.createEmailPasswordSession(user.email, user.password); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
export async function logoutAccount() { | ||
try { | ||
return await account.deleteSession('current'); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
export async function getUserWeeklyPick(data: { | ||
userId: string; | ||
weekNumber: string; | ||
}) { | ||
try { | ||
const response = await databases.listDocuments( | ||
appwriteConfig.databaseId, | ||
'66313025000612a5380e', | ||
); | ||
return response.documents[0].userResults; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
export async function getAllWeeklyPicks() { | ||
try { | ||
const response = await databases.listDocuments( | ||
appwriteConfig.databaseId, | ||
'66313025000612a5380e', | ||
); | ||
return response; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
export async function getNFLTeams() { | ||
try { | ||
return await databases.listDocuments( | ||
appwriteConfig.databaseId, | ||
'662152bfabacfbda3bb3', | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
export async function registerAccount(request: { | ||
email: string; | ||
password: string; | ||
}) { | ||
const { email, password } = request; | ||
|
||
try { | ||
return await account.create(ID.unique(), email, password); | ||
} catch (error: any) { | ||
throw error; | ||
} | ||
} | ||
|
||
export async function createWeeklyPicks(data: { | ||
gameId: string; | ||
gameWeekId: string; | ||
userResults: string; | ||
}) { | ||
try { | ||
return await databases.updateDocument( | ||
appwriteConfig.databaseId, | ||
'66313025000612a5380e', | ||
'663130a100297f77c3c8', | ||
data, | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} |
Oops, something went wrong.
61e2997
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
gridiron-survivor – ./
gridiron-survivor-git-main-letsgettechnical.vercel.app
gridironsurvivor.com
gridiron-survivor-letsgettechnical.vercel.app
www.gridironsurvivor.com