Skip to content

Conversation

@Hesara2003
Copy link
Contributor

@Hesara2003 Hesara2003 commented Jan 15, 2026

Description

Adds unit tests for the custom no-consecutive-headings markdownlint rule which previously had no test coverage.

Changes

  • Added lint-config/no-consecutive-headings.test.js with 17 test cases
  • Uses Node.js built-in assert module (no external dependencies)
  • Can be run with: node lint-config/no-consecutive-headings.test.js

Test Coverage

Category Tests
Rule metadata validation 4
Valid cases (should NOT error) 5
Invalid cases (SHOULD error) 5
Edge cases 3

All 17 tests pass ✅

Why This Matters

The custom lint rule enforces documentation style guidelines but had no tests to verify its behavior. This PR adds comprehensive test coverage to catch regressions during future changes.

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for the no-consecutive-headings rule, validating proper detection of violations across various content types and edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link

CLAassistant commented Jan 15, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

Walkthrough

Introduces a comprehensive unit test suite for the no-consecutive-headings markdownlint rule, covering rule metadata validation, valid cases with separated headings, invalid cases detecting consecutive headings, and edge cases with assertions for error messages and line numbers.

Changes

Cohort / File(s) Summary
Test Suite for no-consecutive-headings Rule
lint-config/no-consecutive-headings.test.js
Adds 214-line test file with custom test framework, rule metadata validation (name, description, tags), valid test cases (headings separated by paragraphs, code fences, blockquotes, lists), invalid test cases (consecutive headings, multiple errors, line number assertions), and edge cases (empty documents, no headings, blank line scenarios).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A test file hops into view,
Checking headings, both false and true,
No consecutive peaks shall escape,
With cases galore, in perfect shape! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is comprehensive and covers purpose, changes, and test coverage details, but lacks alignment with the repository's required template sections (security checks, test environment, etc.). While the custom description is informative, consider aligning with the repository template by adding the required sections: Purpose, Test environment, and Security checks (even if just to confirm N/A for a test file).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding unit tests for the no-consecutive-headings markdownlint rule.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c82994 and a9c425f.

📒 Files selected for processing (1)
  • lint-config/no-consecutive-headings.test.js
🔇 Additional comments (9)
lint-config/no-consecutive-headings.test.js (9)

1-11: LGTM!

Clear documentation and appropriate setup for a standalone test file. The shebang enables direct execution, and using the built-in assert module keeps dependencies minimal.


14-42: Mock implementation is adequate for current tests.

The simplified token generation covers the essential cases needed to test the no-consecutive-headings rule. Note that it doesn't generate closing tokens for blockquotes/lists or handle numbered lists, but these gaps don't affect the rule's logic since it only checks for heading tokens and the presence of intervening content tokens.


44-50: LGTM!

Clean helper that encapsulates the rule invocation and error collection pattern.


52-71: LGTM!

Simple yet effective test runner implementation. The synchronous execution model is appropriate for these stateless unit tests.


76-92: LGTM!

Good coverage of rule metadata validation, ensuring the rule exports conform to markdownlint's expected interface.


94-142: LGTM!

Comprehensive coverage of valid cases, testing all major content types that should separate headings (paragraphs, code blocks, lists, blockquotes). Test names clearly describe the expected behavior.


144-185: LGTM!

Solid coverage of invalid cases with appropriate assertions. The tests verify not just that errors are reported, but also validate error properties (line numbers, context, detail message).


187-207: LGTM!

Important edge cases covered, especially the test confirming that blank lines alone don't qualify as separating content between headings.


209-214: LGTM!

Proper exit code handling enables CI integration—the script will fail the pipeline if any tests fail.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants