diff --git a/src/Components/Nav/Search.js b/src/Components/Nav/Search.js
index 2d0ece6..ab3ffbf 100644
--- a/src/Components/Nav/Search.js
+++ b/src/Components/Nav/Search.js
@@ -77,13 +77,14 @@ export default function Search({ searchResults }) {
/>
{showRecommendations && search && (
-
+
{recommendations && recommendations.length > 0 ? (
recommendations.map((restaurant) => (
- goToSearchResult(restaurant.id)}
+ data-testid="recommend-result"
>
{restaurant.name}
diff --git a/src/Dummy/SearchResults.js b/src/Dummy/SearchResults.js
new file mode 100644
index 0000000..4d2c2f6
--- /dev/null
+++ b/src/Dummy/SearchResults.js
@@ -0,0 +1,1524 @@
+ export let pizza = [
+
+ {
+ info: {
+ id: "10576",
+ name: "Pizza Hut",
+ cloudinaryImageId: "2b4f62d606d1b2bfba9ba9e5386fabb7",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹350 for two",
+ cuisines: ["Pizzas"],
+ avgRating: 4,
+ parentId: "721",
+ avgRatingString: "4.0",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 22,
+ lastMileTravel: 0.7,
+ serviceability: "SERVICEABLE",
+ slaString: "22 mins",
+ lastMileTravelString: "0.7 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 04:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/pizza-hut-koramangala-bangalore-10576",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "108424",
+ name: "Domino's Pizza",
+ cloudinaryImageId: "vw6n5betlssnqelt7rmu",
+ locality: "5TH Block",
+ areaName: "Koramangala",
+ costForTwo: "₹400 for two",
+ cuisines: ["Pizzas", "Italian", "Pastas", "Desserts"],
+ avgRating: 4.4,
+ parentId: "2456",
+ avgRatingString: "4.4",
+ totalRatingsString: "5K+",
+ sla: {
+ deliveryTime: 25,
+ serviceability: "SERVICEABLE",
+ slaString: "25 mins",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 00:59:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/dominos-pizza-5th-block-koramangala-bangalore-108424",
+ type: "WEBLINK",
+ },
+ }
+ ]
+
+ let allRes = [
+ {
+ info: {
+ id: "65797",
+ name: "Leon's - Burgers & Wings (Leon Grill)",
+ cloudinaryImageId: "b2edbc28b7b8219d6e0a9c049ce06658",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹300 for two",
+ cuisines: [
+ "American",
+ "Snacks",
+ "Turkish",
+ "Portuguese",
+ "Continental",
+ ],
+ avgRating: 4.4,
+ parentId: "371281",
+ avgRatingString: "4.4",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 19,
+ lastMileTravel: 1.4,
+ serviceability: "SERVICEABLE",
+ slaString: "19 mins",
+ lastMileTravelString: "1.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 04:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/leons-burgers-and-wings-leon-grill-koramangala-bangalore-65797",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "18973",
+ name: "Nandhana Palace",
+ cloudinaryImageId: "195876a3181ef63f76e45e3a7b49b585",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹500 for two",
+ cuisines: [
+ "Biryani",
+ "Andhra",
+ "South Indian",
+ "North Indian",
+ ],
+ avgRating: 4.2,
+ parentId: "2120",
+ avgRatingString: "4.2",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 18,
+ lastMileTravel: 0.6,
+ serviceability: "SERVICEABLE",
+ slaString: "18 mins",
+ lastMileTravelString: "0.6 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 02:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/nandhana-palace-koramangala-bangalore-18973",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "10576",
+ name: "Pizza Hut",
+ cloudinaryImageId: "2b4f62d606d1b2bfba9ba9e5386fabb7",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹350 for two",
+ cuisines: ["Pizzas"],
+ avgRating: 4,
+ parentId: "721",
+ avgRatingString: "4.0",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 22,
+ lastMileTravel: 0.7,
+ serviceability: "SERVICEABLE",
+ slaString: "22 mins",
+ lastMileTravelString: "0.7 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 04:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/pizza-hut-koramangala-bangalore-10576",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "25620",
+ name: "KFC",
+ cloudinaryImageId: "f01666ac73626461d7455d9c24005cd4",
+ locality: "Intermediate Ring Road",
+ areaName: "Ejipura",
+ costForTwo: "₹400 for two",
+ cuisines: [
+ "Burgers",
+ "Biryani",
+ "American",
+ "Snacks",
+ "Fast Food",
+ ],
+ avgRating: 4.2,
+ parentId: "547",
+ avgRatingString: "4.2",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 17,
+ lastMileTravel: 0.8,
+ serviceability: "SERVICEABLE",
+ slaString: "17 mins",
+ lastMileTravelString: "0.8 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "EVERY ITEM",
+ subHeader: "@ ₹179",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/kfc-intermediate-ring-road-ejipura-bangalore-25620",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "50467",
+ name: "Bakingo",
+ cloudinaryImageId: "0c53fd8f62e3d25ba56d1b4cfe572cef",
+ locality: "1st Block",
+ areaName: "Koramangala",
+ costForTwo: "₹300 for two",
+ cuisines: ["Bakery", "Desserts", "Beverages", "Snacks"],
+ avgRating: 4.3,
+ parentId: "3818",
+ avgRatingString: "4.3",
+ totalRatingsString: "5K+",
+ sla: {
+ deliveryTime: 21,
+ lastMileTravel: 2.5,
+ serviceability: "SERVICEABLE",
+ slaString: "21 mins",
+ lastMileTravelString: "2.5 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 01:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/bakingo-1st-block-koramangala-bangalore-50467",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "293095",
+ name: "Barbeque Nation",
+ cloudinaryImageId: "vgksvwfy7ybng94snjtx",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹600 for two",
+ cuisines: [
+ "North Indian",
+ "Barbecue",
+ "Biryani",
+ "Kebabs",
+ "Mughlai",
+ "Desserts",
+ ],
+ avgRating: 3.7,
+ parentId: "2438",
+ avgRatingString: "3.7",
+ totalRatingsString: "1K+",
+ sla: {
+ deliveryTime: 30,
+ lastMileTravel: 2.2,
+ serviceability: "SERVICEABLE",
+ slaString: "30 mins",
+ lastMileTravelString: "2.2 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:30:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/barbeque-nation-koramangala-bangalore-293095",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "140887",
+ name: "McDonald's",
+ cloudinaryImageId: "bb7ae131544c7d37e10fc5faf76f09d6",
+ locality: "Mantri Avenue",
+ areaName: "Koramangala",
+ costForTwo: "₹400 for two",
+ cuisines: ["Burgers", "Beverages", "Cafe", "Desserts"],
+ avgRating: 4.5,
+ parentId: "630",
+ avgRatingString: "4.5",
+ totalRatingsString: "5K+",
+ sla: {
+ deliveryTime: 18,
+ lastMileTravel: 1.4,
+ serviceability: "SERVICEABLE",
+ slaString: "18 mins",
+ lastMileTravelString: "1.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:45:00",
+ opened: true,
+ },
+ badges: {
+ textExtendedBadges: [
+ {
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ fontColor: "#7E808C",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "",
+ fontColor: "#7E808C",
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ },
+ },
+ ],
+ },
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/mcdonalds-mantri-avenue-koramangala-bangalore-140887",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "5934",
+ name: "Burger King",
+ cloudinaryImageId: "e33e1d3ba7d6b2bb0d45e1001b731fcf",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹350 for two",
+ cuisines: ["Burgers", "American"],
+ avgRating: 4.2,
+ parentId: "166",
+ avgRatingString: "4.2",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 21,
+ lastMileTravel: 1.6,
+ serviceability: "SERVICEABLE",
+ slaString: "21 mins",
+ lastMileTravelString: "1.6 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 05:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/burger-king-koramangala-bangalore-5934",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "50842",
+ name: "CakeZone",
+ cloudinaryImageId: "e386a679bad57c2527925e5a22cd283a",
+ locality: "KORAMANGLA",
+ areaName: "6th Block",
+ costForTwo: "₹200 for two",
+ cuisines: ["Bakery", "Desserts", "Sweets", "Ice Cream"],
+ avgRating: 4.4,
+ parentId: "7003",
+ avgRatingString: "4.4",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 17,
+ lastMileTravel: 0.7,
+ serviceability: "SERVICEABLE",
+ slaString: "17 mins",
+ lastMileTravelString: "0.7 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 01:00:00",
+ opened: true,
+ },
+ badges: {
+ textExtendedBadges: [
+ {
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ fontColor: "#7E808C",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "",
+ fontColor: "#7E808C",
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ },
+ },
+ ],
+ },
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/cakezone-koramangla-6th-block-bangalore-50842",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "506324",
+ name: "Louis Burger",
+ cloudinaryImageId: "19d3d352cc815b9d88b22617b41fa97b",
+ locality: "6Th Block, Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹600 for two",
+ cuisines: ["Burgers", "American", "Fast Food"],
+ avgRating: 4.4,
+ parentId: "22485",
+ avgRatingString: "4.4",
+ totalRatingsString: "1K+",
+ sla: {
+ deliveryTime: 23,
+ lastMileTravel: 1.4,
+ serviceability: "SERVICEABLE",
+ slaString: "23 mins",
+ lastMileTravelString: "1.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 04:00:00",
+ opened: true,
+ },
+ badges: {
+ imageBadges: [
+ {
+ imageId: "newg.png",
+ description: "Gourmet",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "Gourmet",
+ imageId: "newg.png",
+ },
+ },
+ ],
+ },
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/louis-burger-6th-block-koramangala-bangalore-506324",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "293023",
+ name: "Istah - The Mediterranean Way",
+ cloudinaryImageId: "9a01f2935fcb5ae05426db8264062102",
+ locality: "6th Block",
+ areaName: "Koramangala",
+ costForTwo: "₹250 for two",
+ cuisines: [
+ "Mediterranean",
+ "Snacks",
+ "Biryani",
+ "Grill",
+ "Kebabs",
+ "Arabian",
+ "Lebanese",
+ "Beverages",
+ "Desserts",
+ "Italian",
+ "Turkish",
+ ],
+ avgRating: 4.5,
+ parentId: "3518",
+ avgRatingString: "4.5",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 18,
+ lastMileTravel: 0.7,
+ serviceability: "SERVICEABLE",
+ slaString: "18 mins",
+ lastMileTravelString: "0.7 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 02:00:00",
+ opened: true,
+ },
+ badges: {
+ imageBadges: [
+ {
+ imageId:
+ "v1690360529/Ratnesh_Badges/Only_on_swiggy_badge_4x.png",
+ description: "OnlyOnSwiggy",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "OnlyOnSwiggy",
+ imageId:
+ "v1690360529/Ratnesh_Badges/Only_on_swiggy_badge_4x.png",
+ },
+ },
+ ],
+ },
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/istah-the-mediterranean-way-6th-block-koramangala-bangalore-293023",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "108424",
+ name: "Domino's Pizza",
+ cloudinaryImageId: "vw6n5betlssnqelt7rmu",
+ locality: "5TH Block",
+ areaName: "Koramangala",
+ costForTwo: "₹400 for two",
+ cuisines: ["Pizzas", "Italian", "Pastas", "Desserts"],
+ avgRating: 4.4,
+ parentId: "2456",
+ avgRatingString: "4.4",
+ totalRatingsString: "5K+",
+ sla: {
+ deliveryTime: 25,
+ serviceability: "SERVICEABLE",
+ slaString: "25 mins",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 00:59:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/dominos-pizza-5th-block-koramangala-bangalore-108424",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "52992",
+ name: "Sweet Truth - Cake and Desserts",
+ cloudinaryImageId: "81cf6bfe2760a45a0caf2e28716ca4d7",
+ locality: "Jakkasandra",
+ areaName: "Hsr Layout 5th Sector",
+ costForTwo: "₹450 for two",
+ cuisines: ["Snacks", "Bakery", "Desserts", "Beverages"],
+ avgRating: 4.4,
+ parentId: "4444",
+ avgRatingString: "4.4",
+ totalRatingsString: "1K+",
+ sla: {
+ deliveryTime: 22,
+ lastMileTravel: 2.4,
+ serviceability: "SERVICEABLE",
+ slaString: "22 mins",
+ lastMileTravelString: "2.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:59:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/sweet-truth-cake-and-desserts-jakkasandra-hsr-layout-5th-sector-bangalore-52992",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "158855",
+ name: "Candice's Gourmet Sandwiches & Wraps",
+ cloudinaryImageId: "d1331113564b015c9d55c48ff48a2553",
+ locality: "5th Block",
+ areaName: "Koramangala",
+ costForTwo: "₹600 for two",
+ cuisines: [
+ "Continental",
+ "American",
+ "Salads",
+ "Desserts",
+ "Beverages",
+ "Healthy Food",
+ ],
+ avgRating: 4.6,
+ parentId: "465403",
+ avgRatingString: "4.6",
+ totalRatingsString: "1K+",
+ sla: {
+ deliveryTime: 22,
+ lastMileTravel: 0.4,
+ serviceability: "SERVICEABLE",
+ slaString: "22 mins",
+ lastMileTravelString: "0.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:00:00",
+ opened: true,
+ },
+ badges: {
+ imageBadges: [
+ {
+ imageId: "newg.png",
+ description: "Gourmet",
+ },
+ ],
+ textExtendedBadges: [
+ {
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ fontColor: "#7E808C",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "Gourmet",
+ imageId: "newg.png",
+ },
+ },
+ ],
+ },
+ textBased: {},
+ textExtendedBadges: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "",
+ fontColor: "#7E808C",
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ },
+ },
+ ],
+ },
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/candices-gourmet-sandwiches-and-wraps-5th-block-koramangala-bangalore-158855",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "41913",
+ name: "Chinita Real Mexican Food",
+ cloudinaryImageId: "29fc772cc06b07a4b018e4971d96c9a3",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹750 for two",
+ cuisines: ["Mexican", "Salads", "Desserts", "Beverages"],
+ avgRating: 4.5,
+ parentId: "5064",
+ avgRatingString: "4.5",
+ totalRatingsString: "5K+",
+ sla: {
+ deliveryTime: 20,
+ lastMileTravel: 0.4,
+ serviceability: "SERVICEABLE",
+ slaString: "20 mins",
+ lastMileTravelString: "0.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:00:00",
+ opened: true,
+ },
+ badges: {
+ imageBadges: [
+ {
+ imageId: "newg.png",
+ description: "Gourmet",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "Gourmet",
+ imageId: "newg.png",
+ },
+ },
+ ],
+ },
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/chinita-real-mexican-food-koramangala-bangalore-41913",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "425",
+ name: "Hotel Empire",
+ cloudinaryImageId: "un4omn7rcunkmlw6vikr",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹450 for two",
+ cuisines: ["North Indian", "Kebabs", "Biryani"],
+ avgRating: 4.3,
+ parentId: "475",
+ avgRatingString: "4.3",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 29,
+ lastMileTravel: 1.3,
+ serviceability: "SERVICEABLE",
+ slaString: "29 mins",
+ lastMileTravelString: "1.3 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 03:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/hotel-empire-koramangala-bangalore-425",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "42060",
+ name: "Sharief Bhai",
+ cloudinaryImageId: "9ca4ac15ca5cdee1e71efe15909d465f",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹400 for two",
+ cuisines: [
+ "Biryani",
+ "Mughlai",
+ "Arabian",
+ "Kebabs",
+ "Desserts",
+ "Beverages",
+ ],
+ avgRating: 4.2,
+ parentId: "5734",
+ avgRatingString: "4.2",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 23,
+ lastMileTravel: 1.6,
+ serviceability: "SERVICEABLE",
+ slaString: "23 mins",
+ lastMileTravelString: "1.6 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 03:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/sharief-bhai-koramangala-bangalore-42060",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "68144",
+ name: "WarmOven Cake & Desserts",
+ cloudinaryImageId: "e938fb5f416cc2c28b4b519cf27b04cc",
+ locality: "6th Block",
+ areaName: "Koramangala",
+ costForTwo: "₹200 for two",
+ cuisines: [
+ "Bakery",
+ "Desserts",
+ "Ice Cream",
+ "Beverages",
+ ],
+ avgRating: 4.3,
+ parentId: "9696",
+ avgRatingString: "4.3",
+ totalRatingsString: "5K+",
+ sla: {
+ deliveryTime: 21,
+ lastMileTravel: 0.1,
+ serviceability: "SERVICEABLE",
+ slaString: "21 mins",
+ lastMileTravelString: "0.1 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 05:00:00",
+ opened: true,
+ },
+ badges: {},
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {},
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/warmoven-cake-and-desserts-6th-block-koramangala-bangalore-68144",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "108097",
+ name: "Ambur Star Briyani Since 1890",
+ cloudinaryImageId: "yktanq9i7yfjrixaghuj",
+ locality: "2nd Stage",
+ areaName: "BTM Layout",
+ costForTwo: "₹500 for two",
+ cuisines: [
+ "Biryani",
+ "Chettinad",
+ "Andhra",
+ "Beverages",
+ "Seafood",
+ ],
+ avgRating: 4.4,
+ parentId: "21400",
+ avgRatingString: "4.4",
+ totalRatingsString: "10K+",
+ sla: {
+ deliveryTime: 21,
+ lastMileTravel: 3,
+ serviceability: "SERVICEABLE",
+ slaString: "21 mins",
+ lastMileTravelString: "3.0 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-04 23:45:00",
+ opened: true,
+ },
+ badges: {
+ textExtendedBadges: [
+ {
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ fontColor: "#7E808C",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {},
+ textBased: {},
+ textExtendedBadges: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "",
+ fontColor: "#7E808C",
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ },
+ },
+ ],
+ },
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/ambur-star-briyani-since-1890-2nd-stage-btm-layout-bangalore-108097",
+ type: "WEBLINK",
+ },
+ },
+ {
+ info: {
+ id: "381853",
+ name: "ITC Master Chef Creations",
+ cloudinaryImageId: "b15a2367ff3d6f0bf92d1def3c1e5c59",
+ locality: "Koramangala",
+ areaName: "Koramangala",
+ costForTwo: "₹650 for two",
+ cuisines: [
+ "North Indian",
+ "Biryani",
+ "Indian",
+ "Punjabi",
+ "Chaat",
+ "Kebabs",
+ "Tandoor",
+ "Mughlai",
+ "Desserts",
+ "Snacks",
+ ],
+ avgRating: 4.5,
+ parentId: "11992",
+ avgRatingString: "4.5",
+ totalRatingsString: "1K+",
+ sla: {
+ deliveryTime: 32,
+ lastMileTravel: 1.4,
+ serviceability: "SERVICEABLE",
+ slaString: "32 mins",
+ lastMileTravelString: "1.4 km",
+ iconType: "ICON_TYPE_EMPTY",
+ },
+ availability: {
+ nextCloseTime: "2024-01-05 00:00:00",
+ opened: true,
+ },
+ badges: {
+ imageBadges: [
+ {
+ imageId: "newg.png",
+ description: "Gourmet",
+ },
+ ],
+ textExtendedBadges: [
+ {
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ fontColor: "#7E808C",
+ },
+ ],
+ },
+ isOpen: true,
+ type: "F",
+ badgesV2: {
+ entityBadges: {
+ imageBased: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "Gourmet",
+ imageId: "newg.png",
+ },
+ },
+ ],
+ },
+ textBased: {},
+ textExtendedBadges: {
+ badgeObject: [
+ {
+ attributes: {
+ description: "",
+ fontColor: "#7E808C",
+ iconId: "guiltfree/GF_Logo_android_3x",
+ shortDescription: "options available",
+ },
+ },
+ ],
+ },
+ },
+ },
+ aggregatedDiscountInfoV3: {
+ header: "₹120 OFF",
+ subHeader: "ABOVE ₹199",
+ discountTag: "FLAT DEAL",
+ },
+ differentiatedUi: {
+ displayType: "ADS_UI_DISPLAY_TYPE_ENUM_DEFAULT",
+ differentiatedUiMediaDetails: {
+ mediaType: "ADS_MEDIA_ENUM_IMAGE",
+ lottie: {},
+ video: {},
+ },
+ },
+ reviewsSummary: {},
+ displayType: "RESTAURANT_DISPLAY_TYPE_DEFAULT",
+ restaurantOfferPresentationInfo: {},
+ },
+ analytics: {},
+ cta: {
+ link: "https://www.swiggy.com/restaurants/itc-master-chef-creations-koramangala-bangalore-381853",
+ type: "WEBLINK",
+ },
+ },
+ ]
\ No newline at end of file
diff --git a/src/__tests__/header.test.js b/src/__tests__/header.test.js
index bb9c005..5abf801 100644
--- a/src/__tests__/header.test.js
+++ b/src/__tests__/header.test.js
@@ -1,4 +1,4 @@
-const { render } = require("@testing-library/react");
+const { render, fireEvent,waitFor } = require("@testing-library/react");
jest.mock("firebase/auth", () => {
return {
getAuth: jest.fn().mockReturnValue({
@@ -13,21 +13,81 @@ import { Provider } from "react-redux";
import store from "../Store/store.js";
import "@testing-library/jest-dom";
import { StaticRouter } from "react-router-dom/server";
-test("Header Component is loaded on App start", () => {
- const header = render(
-
+import { pizza } from "../Dummy/SearchResults.js";
+global.fetch = jest.fn(()=>{
+ return Promise.resolve({
+ json:()=> Promise.resolve(pizza)
+ })
+})
+describe('Header component',()=>{
+ test("Header Component is loaded on App start", () => {
+ const header = render(
+
+
+
+
+
+ );
+ const headerDiv = header.getByTestId("header");
+ const logo = header.getByTestId("app-logo");
+ const appName = header.getByTestId("app-name");
+ const searchBar = header.getByTestId("search-bar");
+
+ expect(headerDiv.children.length).toBe(3);
+ expect(logo.src).toBe("https://i.imgur.com/c5XOd0b.png");
+ expect(appName.innerHTML).toBe("Zungry");
+ expect(searchBar.value).toBe("");
+ });
+
+ test('Search field shows recommendation and hide when focus is removed',async()=>{
+ let header = render(
+
+
+
-
- );
- const headerDiv = header.getByTestId("header");
- const logo = header.getByTestId("app-logo");
- const appName = header.getByTestId("app-name");
- const searchBar = header.getByTestId("search-bar");
+
+ );
+ const searchBar = header.getByTestId("search-bar");
+ const headerDiv = header.getByTestId("header");
+ fireEvent.change(searchBar,{
+ target:{
+ value:'Pizza'
+ }
+ });
+ await waitFor(()=>{
+ expect(header.queryAllByTestId('recommend-result').length).toBe(2)
+ });
+ fireEvent.focus(headerDiv);
+ await waitFor(()=>{
+ expect(header.queryByTestId('recommendation')).toBeNull();
+ });
+ fireEvent.focus(searchBar);
+ await waitFor(()=>{
+ expect(header.queryAllByTestId('recommend-result').length).toBe(2)
+ });
+ })
+ test('Remove recommendations when user clicks on clear button',async ()=>{
+ let header = render(
+
- expect(headerDiv.children.length).toBe(3);
- expect(logo.src).toBe("https://i.imgur.com/c5XOd0b.png");
- expect(appName.innerHTML).toBe("Zungry");
- expect(searchBar.value).toBe("");
-});
+
+
+
+
+
+ );
+ const searchBar = header.getByTestId("search-bar");
+ fireEvent.change(searchBar,{
+ target:{
+ value:'Pizza'
+ }
+ });
+ fireEvent.blur(searchBar);
+ fireEvent.focus(searchBar);
+ await waitFor(()=>{
+ expect(header.queryByTestId('recommendation')).toBeNull();
+ });
+ })
+})