update /theme to new slash command arch (#3791)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com>
This commit is contained in:
haroldmciver-go
2025-07-11 16:01:28 -04:00
committed by GitHub
parent 2826c7a1c6
commit 4197f30278
7 changed files with 102 additions and 14 deletions

View File

@@ -10,6 +10,7 @@ import { type SlashCommand } from '../ui/commands/types.js';
import { memoryCommand } from '../ui/commands/memoryCommand.js';
import { helpCommand } from '../ui/commands/helpCommand.js';
import { clearCommand } from '../ui/commands/clearCommand.js';
import { themeCommand } from '../ui/commands/themeCommand.js';
// Mock the command modules to isolate the service from the command implementations.
vi.mock('../ui/commands/memoryCommand.js', () => ({
@@ -21,6 +22,9 @@ vi.mock('../ui/commands/helpCommand.js', () => ({
vi.mock('../ui/commands/clearCommand.js', () => ({
clearCommand: { name: 'clear', description: 'Mock Clear' },
}));
vi.mock('../ui/commands/themeCommand.js', () => ({
themeCommand: { name: 'theme', description: 'Mock Theme' },
}));
describe('CommandService', () => {
describe('when using default production loader', () => {
@@ -46,25 +50,26 @@ describe('CommandService', () => {
const tree = commandService.getCommands();
// Post-condition assertions
expect(tree.length).toBe(3);
expect(tree.length).toBe(4);
const commandNames = tree.map((cmd) => cmd.name);
expect(commandNames).toContain('memory');
expect(commandNames).toContain('help');
expect(commandNames).toContain('clear');
expect(commandNames).toContain('theme');
});
it('should overwrite any existing commands when called again', async () => {
// Load once
await commandService.loadCommands();
expect(commandService.getCommands().length).toBe(3);
expect(commandService.getCommands().length).toBe(4);
// Load again
await commandService.loadCommands();
const tree = commandService.getCommands();
// Should not append, but overwrite
expect(tree.length).toBe(3);
expect(tree.length).toBe(4);
});
});
@@ -76,8 +81,13 @@ describe('CommandService', () => {
await commandService.loadCommands();
const loadedTree = commandService.getCommands();
expect(loadedTree.length).toBe(3);
expect(loadedTree).toEqual([clearCommand, helpCommand, memoryCommand]);
expect(loadedTree.length).toBe(4);
expect(loadedTree).toEqual([
clearCommand,
helpCommand,
memoryCommand,
themeCommand,
]);
});
});
});