apache / apache/cordova-electron

Review & fix prepare.spec

Open
#126 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
135
Forks
60
Avg merge
1d 6h
Merged PRs (30d)
5

Description

During the review of #121 I noticed that the tests in the `describe('module.exports.prepare method'` block in `tests/spec/unit/templates/cordova/lib/prepare.spec.js` were in pretty bad shape.

Funky stuff going on there:

- instance methods being mocked with arrow functions to return `this`
- massive amount of mock setup and expectations duplicated among the tests
- test bodies wrapped in asynchronous wrapper although nothing apparently asynchronous is going on there (or at leas it is not handled correctly)

Contributor guide

Open the contributing guide

Research direction

Open tests/spec/unit/templates/cordova/lib/prepare.spec.js and inspect the describe('module.exports.prepare method' block first. Review the existing mocks, expectations, and async wrappers, then run the focused prepare.spec tests; done means the duplicated setup is reduced, instance methods are mocked appropriately, unnecessary async handling is removed, and the tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.