From 158a99d87837f59aee141bf4cd0172505080a35c Mon Sep 17 00:00:00 2001 From: Aaron Couch Date: Fri, 13 Sep 2024 16:02:59 -0400 Subject: [PATCH] Update test --- .../tests/api/OpportunityListingApi.test.ts | 110 +++++++++--------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/frontend/tests/api/OpportunityListingApi.test.ts b/frontend/tests/api/OpportunityListingApi.test.ts index 43a08e449..c59823c9f 100644 --- a/frontend/tests/api/OpportunityListingApi.test.ts +++ b/frontend/tests/api/OpportunityListingApi.test.ts @@ -1,5 +1,5 @@ -import { ApiResponse } from "../../src/types/opportunity/opportunityResponseTypes"; -import OpportunityListingAPI from "../../src/app/api/OpportunityListingAPI"; +import { OpportunityApiResponse } from "src/types/opportunity/opportunityResponseTypes"; +import OpportunityListingAPI from "src/app/api/OpportunityListingAPI"; jest.mock("src/app/api/BaseApi"); @@ -16,7 +16,7 @@ describe("OpportunityListingAPI", () => { }); it("should return opportunity data for a valid ID", async () => { - const mockResponse: ApiResponse = getValidMockResponse(); + const mockResponse: OpportunityApiResponse = getValidMockResponse(); mockedRequest.mockResolvedValue(mockResponse); @@ -43,61 +43,59 @@ describe("OpportunityListingAPI", () => { function getValidMockResponse() { return { - data: [ - { - agency: "US-ABC", - category: "discretionary", - category_explanation: null, - created_at: "2024-06-20T18:43:04.555Z", - opportunity_assistance_listings: [ - { - assistance_listing_number: "43.012", - program_title: "Space Technology", - }, - ], - opportunity_id: 12345, - opportunity_number: "ABC-123-XYZ-001", - opportunity_status: "posted", - opportunity_title: "Research into conservation techniques", - summary: { - additional_info_url: "grants.gov", - additional_info_url_description: "Click me for more info", - agency_code: "US-ABC", - agency_contact_description: - "For more information, reach out to Jane Smith at agency US-ABC", - agency_email_address: "fake_email@grants.gov", - agency_email_address_description: "Click me to email the agency", - agency_name: "US Alphabetical Basic Corp", - agency_phone_number: "123-456-7890", - applicant_eligibility_description: - "All types of domestic applicants are eligible to apply", - applicant_types: ["state_governments"], - archive_date: "2024-06-20", - award_ceiling: 100000, - award_floor: 10000, - close_date: "2024-06-20", - close_date_description: "Proposals are due earlier than usual.", - estimated_total_program_funding: 10000000, - expected_number_of_awards: 10, - fiscal_year: 0, - forecasted_award_date: "2024-06-20", - forecasted_close_date: "2024-06-20", - forecasted_close_date_description: - "Proposals will probably be due on this date", - forecasted_post_date: "2024-06-20", - forecasted_project_start_date: "2024-06-20", - funding_categories: ["recovery_act"], - funding_category_description: "Economic Support", - funding_instruments: ["cooperative_agreement"], - is_cost_sharing: true, - is_forecast: false, - post_date: "2024-06-20", - summary_description: - "This opportunity aims to unravel the mysteries of the universe.", + data: { + agency: "US-ABC", + category: "discretionary", + category_explanation: null, + created_at: "2024-06-20T18:43:04.555Z", + opportunity_assistance_listings: [ + { + assistance_listing_number: "43.012", + program_title: "Space Technology", }, - updated_at: "2024-06-20T18:43:04.555Z", + ], + opportunity_id: 12345, + opportunity_number: "ABC-123-XYZ-001", + opportunity_status: "posted", + opportunity_title: "Research into conservation techniques", + summary: { + additional_info_url: "grants.gov", + additional_info_url_description: "Click me for more info", + agency_code: "US-ABC", + agency_contact_description: + "For more information, reach out to Jane Smith at agency US-ABC", + agency_email_address: "fake_email@grants.gov", + agency_email_address_description: "Click me to email the agency", + agency_name: "US Alphabetical Basic Corp", + agency_phone_number: "123-456-7890", + applicant_eligibility_description: + "All types of domestic applicants are eligible to apply", + applicant_types: ["state_governments"], + archive_date: "2024-06-20", + award_ceiling: 100000, + award_floor: 10000, + close_date: "2024-06-20", + close_date_description: "Proposals are due earlier than usual.", + estimated_total_program_funding: 10000000, + expected_number_of_awards: 10, + fiscal_year: 0, + forecasted_award_date: "2024-06-20", + forecasted_close_date: "2024-06-20", + forecasted_close_date_description: + "Proposals will probably be due on this date", + forecasted_post_date: "2024-06-20", + forecasted_project_start_date: "2024-06-20", + funding_categories: ["recovery_act"], + funding_category_description: "Economic Support", + funding_instruments: ["cooperative_agreement"], + is_cost_sharing: true, + is_forecast: false, + post_date: "2024-06-20", + summary_description: + "This opportunity aims to unravel the mysteries of the universe.", }, - ], + updated_at: "2024-06-20T18:43:04.555Z", + }, message: "Success", status_code: 200, };