-
Notifications
You must be signed in to change notification settings - Fork 63
Cicero API Integration
The representatives.test.js file contains tests for the /api/representatives/:zipCode endpoint of an Express.js application. The tests use the Jest testing framework and Supertest library to simulate HTTP requests and responses. The tests mock the Axios library to simulate requests to the Cicero API, which returns data about elected representatives based on a zip code.
The first test checks that the API returns a 200 status code and a single representative object in the response when a valid zip code is provided. The test mocks the Axios library to return a pre-defined response from the Cicero API.
The second test is similar to the first, but it uses the full zip code instead of just the first five digits.
The third test checks that the API returns a 400 status code and an error message in the response when an invalid zip code is provided. The test sets an invalid zip code and expects the API to return an error message that includes the invalid zip code.
The fourth test is commented out, but it would check that the API returns a 500 status code and an error message in the response when the Cicero API is down or not responding to requests from the application server.
- Home
- App Logic
- App Structure
- Getting Started
- Local Environment Setup
- Interacting with the Development Database
- User Background
- Features
- Data Structures
- API Quick Reference
- Single Campaign Mode (Beta)
- Front-end
- Components
- Pages
- State Management
- Amplify API reference (Database)
- Lob Mailing API integration
- Auth0 API Integration
- Stripe API integration
- Cicero API Integration
- Twilio API Integration