2025-08-25 17:02:10 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, it, expect } from 'vitest';
|
2025-09-08 21:59:45 -07:00
|
|
|
import { installCommand } from './install.js';
|
2025-08-25 17:02:10 +00:00
|
|
|
import yargs from 'yargs';
|
2025-09-02 08:15:47 -07:00
|
|
|
|
|
|
|
|
vi.mock('../../config/extension.js', () => ({
|
|
|
|
|
installExtension: vi.fn(),
|
|
|
|
|
}));
|
2025-08-25 17:02:10 +00:00
|
|
|
|
|
|
|
|
describe('extensions install command', () => {
|
|
|
|
|
it('should fail if no source is provided', () => {
|
|
|
|
|
const validationParser = yargs([]).command(installCommand).fail(false);
|
|
|
|
|
expect(() => validationParser.parse('install')).toThrow(
|
2025-09-05 11:44:41 -07:00
|
|
|
'Either source or --path must be provided.',
|
2025-08-25 17:02:10 +00:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should fail if both git source and local path are provided', () => {
|
|
|
|
|
const validationParser = yargs([]).command(installCommand).fail(false);
|
|
|
|
|
expect(() =>
|
2025-09-05 11:44:41 -07:00
|
|
|
validationParser.parse('install some-url --path /some/path'),
|
2025-08-25 17:02:10 +00:00
|
|
|
).toThrow('Arguments source and path are mutually exclusive');
|
|
|
|
|
});
|
|
|
|
|
});
|