package com.slprojects.democultureconceptsinfo;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@WebMvcTest(ShopController.class)
public class ShopControllerTest {
    @Autowired
    private MockMvc mockMvc;

    @Test
    public void testGetAllShops() throws Exception {
        mockMvc.perform(get("/shops"))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$").isArray())
                .andExpect(jsonPath("$[0].itemName").value("Sword"));
    }

    @Test
    public void testGetShop() throws Exception {
        mockMvc.perform(get("/shop").param("itemName", "Sword"))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.itemName").value("Sword"));
    }
}