freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Add unit test coverage for getContentConfig() and getLanguageConfig() in file-handler.ts

Open macerestheo opened this issue 6 months ago • 1 comments

Describe the Issue

The functions getContentConfig() and getLanguageConfig() in curriculum/src/file-handler.ts currently have no unit test coverage.

These functions are pure path-resolution utilities that perform directory existence assertions and return configuration objects used by the curriculum file system layer.

Adding dedicated unit tests would improve:

  • regression protection
  • reliability of path resolution logic
  • confidence during future refactoring
  • documentation of intended behavioral equivalence between both functions

The proposed tests would mock filesystem interactions (existsSync) and validate:

  • expected directory structure generation
  • support for custom base directory overrides
  • equivalence between getContentConfig() and getLanguageConfig()

Affected Page

curriculum/src/file-handler.ts

Your code

expect(contentResult).toEqual(languageResult);

The proposed tests validate that both functions intentionally return equivalent configurations for the same inputs.


Expected behavior

The unit test suite should validate:

  • correct directory structure generation
  • handling of custom directory overrides
  • consistency between both configuration functions
  • stable behavior during future refactoring

The tests should also explicitly document that both functions currently share equivalent behavior.

Screenshots

No response

System

  • Device: Desktop
  • OS: Windows
  • Browser: Chrome
  • Version: Latest

Additional context

Static analysis previously identified duplicated behavior (S4144) between getContentConfig() and getLanguageConfig().

These tests would serve both as regression protection and as explicit behavioral documentation for future maintainers.

macerestheo avatar May 28 '26 23:05 macerestheo

I’d be interested in helping with this if there’s no active PR already covering it.

I’ll take a look at the current implementations in file-handler.ts and work on adding unit tests for:

  • directory structure generation,
  • custom base directory overrides,
  • and behavioral equivalence between getContentConfig() and getLanguageConfig().

I’ll also check the existing test patterns used in the repo for filesystem mocking consistency.

habiibullahm avatar May 29 '26 11:05 habiibullahm

Thank you for reporting this issue.

This is a standard message notifying you that this issue is not on our roadmap at this time, and not something we plan to implement.

If you think we're wrong in closing this issue, please request for it to be reopened and add further clarification. Thank you and happy coding.

camper-chan[bot] avatar Jul 11 '26 14:07 camper-chan[bot]