Amazon-inspired e-commerce front-end project built with vanilla JavaScript, focusing on clean architecture, modular logic, localStorage persistence, and unit testing with Jasmine.
This project is part of my JavaScript learning journey and is actively evolving as new concepts are introduced.
- Products loaded from
data/products.js - Dynamic HTML generation
- Product images, ratings, prices and quantity selector
- Add new products to the cart
- Increase quantity for existing products
- Cart state persisted using
localStorage - Delivery option support
- Cart quantity indicator in header
- Business logic separated from UI logic
- Cart logic isolated inside
data/cart.js - DOM manipulation handled only in
scripts/
- Unit tests for cart logic and utility functions
- Mocking
localStorageusingspyOn - Tests validate both state changes and side effects
- Proper mock order to avoid false positives
This project uses Jasmine for unit testing.
- Open
tests-jasmine/tests.htmlin your browser - All specs should pass with no failures
Current test coverage includes:
formatCurrencyutilityaddToCartlogic (new and existing products)
javascript-amazon-project/
│
├── data/
│ ├── cart.js
│ ├── products.js
│ └── deliveryOptions.js
│
├── scripts/
│ ├── amazon.js
│ ├── checkout.js
│ ├── checkout/
│ │ ├── checkoutHeader.js
│ │ ├── orderSummary.js
│ │ └── paymentSummary.js
│ └── utils/
│ └── money.js
│
├── tests-jasmine/
│ ├── data/
│ │ └── cartTest.js
│ ├── utils/
│ │ └── moneyTest.js
│ └── tests.html
│
├── styles/
├── images/
│
├── index.html
├── checkout.html
├── orders.html
├── tracking.html
└── README.md
- JavaScript (ES6+)
- HTML5
- CSS3
- Jasmine (Unit Testing)
- localStorage API
- Improve checkout logic
- Expand cart test coverage
- Add order history handling
- Improve UI responsiveness
- Add filtering and search functionality
GitHub: https://github.com/jaimeoakes
Portfolio: https://jaimeoakes.github.io/website-portfolio/