-
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
1 parent
2685142
commit 7e0c667
Showing
8 changed files
with
1,337 additions
and
324 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 |
---|---|---|
@@ -1,13 +1,3 @@ | ||
// babel.config.js | ||
module.exports = { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { | ||
node: "current", | ||
}, | ||
}, | ||
], | ||
], | ||
presets: ["@babel/preset-env", "@babel/preset-react"], | ||
}; |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,54 @@ | ||
import React from "react"; | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import { MemoryRouter, Router } from "react-router-dom"; | ||
import { createMemoryHistory } from "history"; | ||
import About from "./About"; | ||
|
||
// Mock environment variable for the test | ||
const originalEnv = process.env; | ||
|
||
beforeAll(() => { | ||
process.env = { | ||
...originalEnv, | ||
REACT_APP_API_URL: "http://test-api-url.com", | ||
}; | ||
}); | ||
|
||
afterAll(() => { | ||
process.env = originalEnv; | ||
}); | ||
|
||
test("renders About component correctly", () => { | ||
render( | ||
<MemoryRouter> | ||
<About /> | ||
</MemoryRouter> | ||
); | ||
|
||
// Check if the header is rendered | ||
expect(screen.getByText(/About MoodMelody/i)).toBeInTheDocument(); | ||
|
||
// Check if the button is rendered | ||
const backButton = screen.getByRole("button", { name: /Back to Playlist/i }); | ||
expect(backButton).toBeInTheDocument(); | ||
}); | ||
|
||
test("navigates back to playlist on button click", () => { | ||
const history = createMemoryHistory(); | ||
history.push = jest.fn(); | ||
|
||
render( | ||
<Router location={history.location} navigator={history}> | ||
<About /> | ||
</Router> | ||
); | ||
|
||
const backButton = screen.getByRole("button", { name: /Back to Playlist/i }); | ||
fireEvent.click(backButton); | ||
|
||
expect(history.push).toHaveBeenCalledWith( | ||
expect.objectContaining({ pathname: "/playlist", hash: "", search: "" }), | ||
undefined, | ||
{} | ||
); | ||
}); |
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,13 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import Footer from "./Footer"; | ||
|
||
test("renders Footer component correctly", () => { | ||
render(<Footer />); | ||
|
||
// Check if footer is rendered | ||
const footerText = screen.getByText( | ||
/© 2024 Mood Melody. All rights reserved./i | ||
); | ||
expect(footerText).toBeInTheDocument(); | ||
}); |
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,35 @@ | ||
import React from "react"; | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import Landing from "./Landing"; | ||
|
||
describe("Landing Component", () => { | ||
test("renders Landing component correctly", () => { | ||
render(<Landing />); | ||
|
||
// Check if the content is rendered | ||
expect(screen.getByText("About Mood Melody")).toBeInTheDocument(); | ||
expect(screen.getByText("Welcome to Mood Melody!")).toBeInTheDocument(); | ||
expect( | ||
screen.getByText(/Authorize Your Spotify Account:/i) | ||
).toBeInTheDocument(); | ||
expect(screen.getByText(/Describe Your Mood:/i)).toBeInTheDocument(); | ||
expect(screen.getByText(/Get Recommendations:/i)).toBeInTheDocument(); | ||
expect(screen.getByText(/Enjoy Your Playlist:/i)).toBeInTheDocument(); | ||
expect(screen.getByText(/Continuous Discovery:/i)).toBeInTheDocument(); | ||
}); | ||
|
||
test("redirects to the authorization endpoint on button click", () => { | ||
// Mock window.location.assign | ||
delete window.location; | ||
window.location = { assign: jest.fn() }; | ||
|
||
render(<Landing />); | ||
|
||
fireEvent.click(screen.getByText("Authorize with Spotify")); | ||
|
||
// Update the test to match the actual URL being used | ||
expect(window.location.assign).toHaveBeenCalledWith( | ||
"http://127.0.0.1:5000/auth/login" | ||
); | ||
}); | ||
}); |
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