summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/extensionsCommand.test.ts
diff options
context:
space:
mode:
authorHarold Mciver <[email protected]>2025-07-15 17:40:09 -0400
committerGitHub <[email protected]>2025-07-15 21:40:09 +0000
commitbf51de1a4d2111af4ece5a6d5567ed69f8f087df (patch)
tree4387256a373d4a74260314c4e6d0155d71b560f3 /packages/cli/src/ui/commands/extensionsCommand.test.ts
parent58f1aa6ceb53df94cc5bba77dc787950be340cb9 (diff)
update `/extensions` to new slash command arch (#4229)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Diffstat (limited to 'packages/cli/src/ui/commands/extensionsCommand.test.ts')
-rw-r--r--packages/cli/src/ui/commands/extensionsCommand.test.ts66
1 files changed, 66 insertions, 0 deletions
diff --git a/packages/cli/src/ui/commands/extensionsCommand.test.ts b/packages/cli/src/ui/commands/extensionsCommand.test.ts
new file mode 100644
index 00000000..a989d9b0
--- /dev/null
+++ b/packages/cli/src/ui/commands/extensionsCommand.test.ts
@@ -0,0 +1,66 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { describe, it, expect } from 'vitest';
+import { extensionsCommand } from './extensionsCommand.js';
+import { type CommandContext } from './types.js';
+import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
+import { MessageType } from '../types.js';
+
+describe('extensionsCommand', () => {
+ let mockContext: CommandContext;
+
+ it('should display "No active extensions." when none are found', async () => {
+ mockContext = createMockCommandContext({
+ services: {
+ config: {
+ getActiveExtensions: () => [],
+ },
+ },
+ });
+
+ if (!extensionsCommand.action) throw new Error('Action not defined');
+ await extensionsCommand.action(mockContext, '');
+
+ expect(mockContext.ui.addItem).toHaveBeenCalledWith(
+ {
+ type: MessageType.INFO,
+ text: 'No active extensions.',
+ },
+ expect.any(Number),
+ );
+ });
+
+ it('should list active extensions when they are found', async () => {
+ const mockExtensions = [
+ { name: 'ext-one', version: '1.0.0' },
+ { name: 'ext-two', version: '2.1.0' },
+ ];
+ mockContext = createMockCommandContext({
+ services: {
+ config: {
+ getActiveExtensions: () => mockExtensions,
+ },
+ },
+ });
+
+ if (!extensionsCommand.action) throw new Error('Action not defined');
+ await extensionsCommand.action(mockContext, '');
+
+ const expectedMessage =
+ 'Active extensions:\n\n' +
+ ` - \u001b[36mext-one (v1.0.0)\u001b[0m\n` +
+ ` - \u001b[36mext-two (v2.1.0)\u001b[0m\n`;
+
+ expect(mockContext.ui.addItem).toHaveBeenCalledWith(
+ {
+ type: MessageType.INFO,
+ text: expectedMessage,
+ },
+ expect.any(Number),
+ );
+ });
+});