This commit introduces several significant improvements:
- **Enhanced Unit Testing:** Vastly improved unit tests for the module, covering core functions, edge cases, and error handling. Simplified test functions and comprehensive mocking were implemented for better isolation and reliability. Added new section to tests.mdc detailing reliable testing techniques.
- **CLI Kebab-Case Flag Enforcement:** The CLI now enforces kebab-case for flags, providing helpful error messages when camelCase is used. This improves consistency and user experience.
- **AI Enhancements:**
- Enabled 128k token output for Claude 3.7 Sonnet by adding the header.
- Added a new task to to document this change and its testing strategy.
- Added unit tests to verify the Anthropic client configuration.
- Added and utility functions.
- **Improved Test Coverage:** Added tests for the new CLI flag validation logic.
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/**
|
|
* Tests for kebab-case validation functionality
|
|
*/
|
|
|
|
import { jest } from '@jest/globals';
|
|
|
|
// Create a mock implementation of the helper function to avoid loading the entire module
|
|
jest.mock('../../bin/task-master.js', () => ({
|
|
detectCamelCaseFlags: jest.requireActual('../../bin/task-master.js').detectCamelCaseFlags
|
|
}));
|
|
|
|
// Import the module after mocking - use dynamic import for ES modules
|
|
import { detectCamelCaseFlags } from '../../scripts/modules/utils.js';
|
|
|
|
describe('Kebab Case Validation', () => {
|
|
test('should properly detect camelCase flags', () => {
|
|
const args = ['node', 'task-master', 'add-task', '--promptText=test', '--userID=123'];
|
|
const flags = detectCamelCaseFlags(args);
|
|
|
|
expect(flags).toHaveLength(2);
|
|
expect(flags).toContainEqual({
|
|
original: 'promptText',
|
|
kebabCase: 'prompt-text'
|
|
});
|
|
expect(flags).toContainEqual({
|
|
original: 'userID',
|
|
kebabCase: 'user-id'
|
|
});
|
|
});
|
|
|
|
test('should not flag kebab-case or lowercase flags', () => {
|
|
const args = ['node', 'task-master', 'add-task', '--prompt=test', '--user-id=123'];
|
|
const flags = detectCamelCaseFlags(args);
|
|
|
|
expect(flags).toHaveLength(0);
|
|
});
|
|
|
|
test('should not flag single-word lowercase flags', () => {
|
|
const args = ['node', 'task-master', 'add-task', '--prompt="test"', '--file=file.json'];
|
|
const flags = detectCamelCaseFlags(args);
|
|
|
|
expect(flags).toHaveLength(0);
|
|
});
|
|
});
|