We are developing an e-commerce application with Angular. One of the key requirements is the ability to search for products in a catalog efficiently. To achieve this, we will implement a binary search to find specific products by their ID.
A repository with a predefined mock of products will be provided to facilitate development. This repository already has Jest and TailwindCSS installed, allowing the candidate to focus on adding the new feature.
Implement a binary search function in Angular to find a product in a catalog ordered by IDs. The function must be efficient and should integrate properly with the rest of the Angular application.
If no product is found, a message "Product not found" should be displayed. If the ID is found, the product details should be displayed, all within the APP component.
Search Component:
- Create a component that allows the user to enter a product ID and display the details of the found product.
Unit Tests:
- Include unit tests for all created components or services, using Jest.
Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.
Run ng build to build the project. The build artifacts will be stored in the dist/ directory.
Run npm run test to execute the unit tests via Jest.