-
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.
- Loading branch information
Showing
12 changed files
with
159 additions
and
44 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,2 @@ | ||
{ | ||
} |
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,7 +1,8 @@ | ||
{ | ||
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */ | ||
"rules": { | ||
".read": true, | ||
".write": true | ||
"courses": { | ||
".read": true, | ||
".write": "auth != null" | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ const App = () => ( | |
</QueryClientProvider> | ||
); | ||
|
||
export default App; | ||
export default App; |
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,28 @@ | ||
import {describe, it, vi} from 'vitest'; | ||
import {render, screen} from '@testing-library/react'; | ||
import App from './App'; | ||
import {useAuthState, useDbData} from './utilities/firebase'; | ||
|
||
const mockSchedule = { | ||
"title": "CS Courses for 1850-1851", | ||
"courses": { | ||
} | ||
}; | ||
|
||
vi.mock('./utilities/firebase'); | ||
|
||
beforeEach(() => { | ||
useDbData.mockReturnValue([mockSchedule, null]); | ||
useAuthState.mockReturnValue([null]); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
describe('launching', () => { | ||
it('should show the current year', () => { | ||
render(<App />); | ||
screen.getByText(/1850/); | ||
}); | ||
}); |
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,19 +1,40 @@ | ||
import {describe, expect, test} from 'vitest'; | ||
import {fireEvent, render, screen} from '@testing-library/react'; | ||
// import {describe, it,} from 'vitest'; | ||
// import {render, screen} from '@testing-library/react'; | ||
// import App from './App'; | ||
|
||
// describe('launching', () => { | ||
// it('should show the current year', async () => { | ||
// render(<App />); | ||
// await screen.findByText(/2018/); | ||
// }); | ||
// }); | ||
|
||
import {describe, it, vi} from 'vitest'; | ||
import {render, screen} from '@testing-library/react'; | ||
import App from './App'; | ||
import {useAuthState, useDbData} from './utilities/firebase'; | ||
|
||
describe('counter tests', () => { | ||
|
||
test("Counter should be 0 at the start", () => { | ||
render(<App />); | ||
expect(screen.getByText('count is: 0')).toBeDefined(); | ||
}); | ||
const mockSchedule = { | ||
"title": "CS Courses for 1850-1851", | ||
"courses": { | ||
} | ||
}; | ||
|
||
vi.mock('./utilities/firebase'); | ||
|
||
beforeEach(() => { | ||
useDbData.mockReturnValue([mockSchedule, null]); | ||
useAuthState.mockReturnValue([null]); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
test("Counter should increment by one when clicked", async () => { | ||
describe('launching', () => { | ||
it('should show the current year', () => { | ||
render(<App />); | ||
const counter = screen.getByRole('button'); | ||
fireEvent.click(counter); | ||
expect(await screen.getByText('count is: 1')).toBeDefined(); | ||
screen.getByText(/1850/); | ||
}); | ||
}); | ||
|
||
}); |
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,5 +1,28 @@ | ||
const Banner = ({title}) => ( | ||
<center><h1>{title}</h1></center> | ||
import { signInWithGoogle, signOut, useAuthState } from "../utilities/firebase"; | ||
|
||
const SignInButton = () => ( | ||
<button className="ms-auto btn btn-outline-success" onClick={signInWithGoogle}>Sign in</button> | ||
); | ||
|
||
const SignOutButton = () => ( | ||
<button className="ms-auto btn btn-outline-danger" onClick={signOut}>Sign out</button> | ||
); | ||
|
||
const AuthButton = () => { | ||
const [user] = useAuthState(); | ||
return user ? <SignOutButton /> : <SignInButton />; | ||
}; | ||
const Banner = ({title}) => { | ||
return( | ||
<div className="tittle"> | ||
<br/> | ||
<center><h1>{title}</h1></center> | ||
<div className="log-in"> | ||
<AuthButton /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
|
||
export default Banner; |
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,14 @@ | ||
import React from 'react'; | ||
import { useParams, useNavigate } from 'react-router-dom'; | ||
import CourseForm from './CourseForm'; | ||
const CourseFormWrapper = ({ courses, user }) => { | ||
const { courseId } = useParams(); // Get the courseId from the URL | ||
const course = courses[courseId]; | ||
const navigate = useNavigate(); | ||
if (!user || !course) { | ||
navigate('/'); | ||
return null; | ||
} | ||
return <CourseForm course={course} courseId={courseId} />; | ||
}; | ||
export default CourseFormWrapper; |
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
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