package shop.backend;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class CartTest {
    private Cart cart;
    private Product product1;
    private Product product2;
    @BeforeEach
    public void testSetup() {
        cart = new Cart();
        product1 = new Product(1, "Product 1", 1.0, 10.0, 19.0, 100);
        product2 = new Product(2, "Product 2", 2.0, 20.0, 7.0, 50);
    }
    @Test
    public void testAdd(){
        cart.addProduct(product1,2);
        cart.updateProductQuantity(1,5);
        assertEquals(5, cart.getPositions().get(0).getQuantity());


    }
    @Test
    public void testClear() {
        cart.addProduct(product1, 2);
        cart.clear();
        assertTrue(cart.isEmpty());
    }

}