projects
projects copied to clipboard
Fix issue 323 prototypes tests
trafficstars
PR Checklist
- [x] Addresses an existing open issue: fixes #323
- [x] That issue was marked as accepting prs
- [x] Steps in CONTRIBUTING.md were taken
Overview
Add comprehensive test suite for the prototypes-to-classes exercise in the-typeinator project.
This PR adds the missing index.test.js file that was requested in issue #323. The test file includes:
- Conditional test skipping: Tests are skipped when
index.jsis empty (learner mode), allowing students to start with clean files - Solution validation: Tests run properly when
TEST_SOLUTIONS=trueis set (validation mode) - Comprehensive coverage: Tests for both Robot and Humanoid classes including:
- Class construction with proper properties
- Method functionality (announce, charge, move)
- Inheritance behavior (Humanoid extends Robot)
- Console output validation with Jest mocks
- Power management and error handling logic
The implementation follows the same pattern established in other test files in the repository, ensuring consistency with the educational workflow.