Skip to content

Commit

Permalink
Merge pull request #45 from AryanK1511/dev-aryan
Browse files Browse the repository at this point in the history
Add unit test for `handleHelpOption()` function
  • Loading branch information
peterdanwan authored Nov 11, 2024
2 parents 3123885 + f025ab4 commit 6b0a0ba
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/unit/option_handlers/handleHelpOption.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// tests/unit/option_handlers/handleHelpOption.test.js
import { jest } from '@jest/globals';
import handleHelpOption from '../../../src/option_handlers/handleHelpOption.js';
import commanderProgram from '../../../src/commander/commanderProgram.js';

describe('src/option_handlers/handleHelpOption.js tests', () => {
test("handleHelpOption() invokes the commander program's help method", () => {
const helpSpy = jest.spyOn(commanderProgram, 'help').mockImplementation(() => {});

handleHelpOption(commanderProgram);

// Proves that passing the commanderProgram to handleHelpOption calls the help
// method on the commanderProgram
expect(helpSpy).toHaveBeenCalled();
helpSpy.mockRestore();
});
});

0 comments on commit 6b0a0ba

Please sign in to comment.