rmdir and touch fig spec tests

This commit is contained in:
Daniel Imms
2025-02-05 05:23:14 -08:00
parent bf3a0f0e89
commit b1cf1fd151
4 changed files with 69 additions and 5 deletions
@@ -421,11 +421,6 @@ function getCompletionItemsFromArgs(args: Fig.SingleOrArray<Fig.Arg> | undefined
if (Array.isArray(arg.template) ? arg.template.includes('folders') : arg.template === 'folders') {
foldersRequested = true;
}
// if (arg.template === 'filepaths') {
// filesRequested = true;
// } else if (arg.template === 'folders') {
// foldersRequested = true;
// }
}
if (arg.suggestions?.length) {
// there are specific suggestions to show
@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import { testPaths, type ISuiteSpec } from '../../helpers';
import rmdirSpec from '../../../completions/upstream/rmdir';
const allOptions = [
'-p',
];
export const rmdirTestSuiteSpec: ISuiteSpec = {
name: 'rmdir',
completionSpecs: rmdirSpec,
availableCommands: 'rmdir',
testSpecs: [
// Empty input
{ input: '|', expectedCompletions: ['rmdir'], expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
// Typing the command
{ input: 'r|', expectedCompletions: ['rmdir'], expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
{ input: 'rmdir|', expectedCompletions: ['rmdir'], expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
// Basic options
{ input: 'rmdir |', expectedCompletions: allOptions, expectedResourceRequests: { type: 'folders', cwd: testPaths.cwd } },
]
};
@@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import { testPaths, type ISuiteSpec } from '../../helpers';
import touchSpec from '../../../completions/upstream/touch';
const allOptions = [
'-A',
'-a',
'-c',
'-f',
'-h',
'-m',
'-r',
'-t',
];
export const touchTestSuiteSpec: ISuiteSpec = {
name: 'touch',
completionSpecs: touchSpec,
availableCommands: 'touch',
testSpecs: [
// Empty input
{ input: '|', expectedCompletions: ['touch'], expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
// Typing the command
{ input: 't|', expectedCompletions: ['touch'], expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
{ input: 'touch|', expectedCompletions: ['touch'], expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
// Basic options
{ input: 'touch |', expectedCompletions: allOptions, expectedResourceRequests: { type: 'folders', cwd: testPaths.cwd } },
]
};
@@ -16,6 +16,8 @@ import { lsTestSuiteSpec } from './completions/upstream/ls.test';
import { echoTestSuiteSpec } from './completions/upstream/echo.test';
import { mkdirTestSuiteSpec } from './completions/upstream/mkdir.test';
import { rmTestSuiteSpec } from './completions/upstream/rm.test';
import { rmdirTestSuiteSpec } from './completions/upstream/rmdir.test';
import { touchTestSuiteSpec } from './completions/upstream/touch.test';
const testSpecs2: ISuiteSpec[] = [
{
@@ -40,6 +42,8 @@ const testSpecs2: ISuiteSpec[] = [
lsTestSuiteSpec,
mkdirTestSuiteSpec,
rmTestSuiteSpec,
rmdirTestSuiteSpec,
touchTestSuiteSpec,
];
suite('Terminal Suggest', () => {