Used promises for async Handlebars function in tests#27586
Conversation
ref 30ab483 This test-only cleanup should have no user impact.
WalkthroughThis change converts test setup across four Handlebars helper test files from callback-driven Mocha patterns to async/await patterns. Specifically, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/test/unit/frontend/helpers/content.test.js (1)
17-22: LGTM — optional: consider extracting a small helper.All three
beforehooks are correctly converted. Since the samepromisify(hbs.cachePartials.bind(hbs))snippet now appears in four test files, you could optionally extract a tiny helper (e.g., intest/utils) likecacheHbsPartials = () => promisify(hbs.cachePartials.bind(hbs))()to DRY it up. Not blocking.Also applies to: 87-96, 224-232
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/test/unit/frontend/helpers/content.test.js` around lines 17 - 22, Extract the repeated promisify(hbs.cachePartials.bind(hbs)) call into a small helper function (e.g., cacheHbsPartials) and replace the inline usage in the before hooks (where hbs.express4 is called and cachePartials is awaited) with a single call to that helper; specifically create a function cacheHbsPartials = () => promisify(hbs.cachePartials.bind(hbs))() and call await cacheHbsPartials() in place of the repeated snippet in tests that reference hbs.cachePartials and promisify so all occurrences (including the ones around the before hooks) use the DRY helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/test/unit/frontend/helpers/content.test.js`:
- Around line 17-22: Extract the repeated promisify(hbs.cachePartials.bind(hbs))
call into a small helper function (e.g., cacheHbsPartials) and replace the
inline usage in the before hooks (where hbs.express4 is called and cachePartials
is awaited) with a single call to that helper; specifically create a function
cacheHbsPartials = () => promisify(hbs.cachePartials.bind(hbs))() and call await
cacheHbsPartials() in place of the repeated snippet in tests that reference
hbs.cachePartials and promisify so all occurrences (including the ones around
the before hooks) use the DRY helper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fe3eab0a-747e-4286-9a42-f4446a5d8f32
📒 Files selected for processing (4)
ghost/core/test/unit/frontend/helpers/cancel-link.test.jsghost/core/test/unit/frontend/helpers/content.test.jsghost/core/test/unit/frontend/helpers/navigation.test.jsghost/core/test/unit/frontend/helpers/pagination.test.js
ref 30ab483
This test-only cleanup should have no user impact.