forked from CodeYourFuture/React-Module-Project
-
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.
Merge pull request #40 from RbAvci/feature/Deck
NW6| Rabia Avci | React Module Project | Feature Deck - Week1
- Loading branch information
Showing
8 changed files
with
56 additions
and
41 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
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
// import Card from "@/components/Card/Card"; | ||
// import "./Deck.scss"; | ||
// import cardsData from "@/data/fakeCards.json"; | ||
import Card from "@/components/Card/Card"; | ||
import "./Deck.scss"; | ||
import cardsData from "@/data/fakeCards.json"; | ||
|
||
// const Deck = () => { | ||
// you will need to map over the cardsData array and render a Card component for each card object | ||
// how will you pass props to the Card component? | ||
const Deck = () => { | ||
return ( | ||
<div className="deck"> | ||
{cardsData.map((cardData, i) => ( | ||
<Card title={cardData.title} url={cardData.url} image={cardData.image} key={i} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
// }; | ||
|
||
// export default Deck; | ||
export default Deck; |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); | ||
gap: var(--space--gap); | ||
} | ||
|
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,9 +1,19 @@ | ||
import Deck from "./Deck.jsx"; | ||
import { describe, it, expect } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import cardsData from "@/data/fakeCards.json"; | ||
|
||
describe("Deck", () => { | ||
it("should have a test, please write one", () => { | ||
return true; | ||
it("renders correct card contents", () => { | ||
render(<Deck />); | ||
|
||
const cards = screen.getAllByTestId("card"); | ||
|
||
cardsData.forEach((cardData, index) => { | ||
const cardElement = cards[index]; | ||
expect(cardElement).toHaveTextContent(cardData.title); | ||
expect(cardElement.querySelector("a")).toHaveAttribute("href", cardData.url); | ||
expect(cardElement.querySelector("img")).toHaveAttribute("src", cardData.image); | ||
}); | ||
}); | ||
}); |
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