generated from Arquisoft/dede_0
-
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
6d86864
commit 5dc56da
Showing
2 changed files
with
78 additions
and
0 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,46 @@ | ||
|
||
|
||
/** | ||
* Test that the OrderAdminCard component is working as expected with a product. | ||
*/ | ||
|
||
import { render } from "@testing-library/react"; | ||
import { ItemCart, Order, Product } from "../../shared/shareddtypes"; | ||
import OrderCard from "./OrderCard"; | ||
|
||
|
||
test('order admin card component can be rendered with a product', async () => { | ||
const order:Order = { | ||
userId: "1", | ||
products: [{ | ||
productId: "1", | ||
product: { | ||
id: "1", | ||
name: "Product 1", | ||
description: "Product 1 description", | ||
price: 10, | ||
image: "", | ||
category: "Test", | ||
reviews: [], | ||
product: {} as Product, | ||
_id: "1", | ||
quantity: 2 | ||
}, | ||
reviewed: false, | ||
quantity: 1, | ||
price:79.99 | ||
}], | ||
subTotal: 69.99, | ||
deliveryPrice: 30, | ||
address: "Test address", | ||
createdAt: new Date("2022-05-02T16:13:17.026+00:00"), | ||
id: "1", | ||
} | ||
|
||
const { getByText } = render(<OrderCard order={order} />); | ||
expect(getByText("Order Mon May 02")).toBeInTheDocument(); | ||
expect(getByText("Total: 69.99 €")).toBeInTheDocument(); | ||
expect(getByText("Shipping cost: 30 €")).toBeInTheDocument(); | ||
} | ||
, 30000); | ||
|
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,32 @@ | ||
|
||
/** | ||
* Check that orderAdminDetails component can be rendered without any error. | ||
*/ | ||
|
||
import { getByText, render } from "@testing-library/react"; | ||
import { Product } from "../../shared/shareddtypes"; | ||
import OrderDetails from "./OrderDetails"; | ||
|
||
test('orderAdminDetails component can be rendered', async () => { | ||
const product = { | ||
productId: "1", | ||
product: { | ||
id: "1", | ||
name: "Product 1", | ||
description: "Product 1 description", | ||
price: 79.99, | ||
image: "", | ||
category: "Test", | ||
reviews: [], | ||
product: {} as Product, | ||
_id: "1", | ||
quantity: 3 | ||
}, | ||
reviewed: false, | ||
quantity: 3, | ||
price:79.99 | ||
} | ||
const { getByText } = render(<OrderDetails productOrdered={product} orderId={"1"}/>); | ||
expect(getByText("Product 1")).toBeInTheDocument(); | ||
expect(getByText("79.99€/unit - 3 units")).toBeInTheDocument(); | ||
}) |