Make CommandTypes a const enum and use allCommandTypes
for unit test
This commit is contained in:
parent
c6e69dd64b
commit
f6240cb6f9
|
@ -172,12 +172,81 @@ namespace ts.server {
|
|||
});
|
||||
|
||||
describe("onMessage", () => {
|
||||
const allCommandNames: CommandNames[] = [
|
||||
CommandNames.Brace,
|
||||
CommandNames.BraceFull,
|
||||
CommandNames.BraceCompletion,
|
||||
CommandNames.Change,
|
||||
CommandNames.Close,
|
||||
CommandNames.Completions,
|
||||
CommandNames.CompletionsFull,
|
||||
CommandNames.CompletionDetails,
|
||||
CommandNames.CompileOnSaveAffectedFileList,
|
||||
CommandNames.Configure,
|
||||
CommandNames.Definition,
|
||||
CommandNames.DefinitionFull,
|
||||
CommandNames.Implementation,
|
||||
CommandNames.ImplementationFull,
|
||||
CommandNames.Exit,
|
||||
CommandNames.Format,
|
||||
CommandNames.Formatonkey,
|
||||
CommandNames.FormatFull,
|
||||
CommandNames.FormatonkeyFull,
|
||||
CommandNames.FormatRangeFull,
|
||||
CommandNames.Geterr,
|
||||
CommandNames.GeterrForProject,
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
CommandNames.SyntacticDiagnosticsSync,
|
||||
CommandNames.NavBar,
|
||||
CommandNames.NavBarFull,
|
||||
CommandNames.Navto,
|
||||
CommandNames.NavtoFull,
|
||||
CommandNames.NavTree,
|
||||
CommandNames.NavTreeFull,
|
||||
CommandNames.Occurrences,
|
||||
CommandNames.DocumentHighlights,
|
||||
CommandNames.DocumentHighlightsFull,
|
||||
CommandNames.Open,
|
||||
CommandNames.Quickinfo,
|
||||
CommandNames.QuickinfoFull,
|
||||
CommandNames.References,
|
||||
CommandNames.ReferencesFull,
|
||||
CommandNames.Reload,
|
||||
CommandNames.Rename,
|
||||
CommandNames.RenameInfoFull,
|
||||
CommandNames.RenameLocationsFull,
|
||||
CommandNames.Saveto,
|
||||
CommandNames.SignatureHelp,
|
||||
CommandNames.SignatureHelpFull,
|
||||
CommandNames.TypeDefinition,
|
||||
CommandNames.ProjectInfo,
|
||||
CommandNames.ReloadProjects,
|
||||
CommandNames.Unknown,
|
||||
CommandNames.OpenExternalProject,
|
||||
CommandNames.CloseExternalProject,
|
||||
CommandNames.SynchronizeProjectList,
|
||||
CommandNames.ApplyChangedToOpenFiles,
|
||||
CommandNames.EncodedSemanticClassificationsFull,
|
||||
CommandNames.Cleanup,
|
||||
CommandNames.OutliningSpans,
|
||||
CommandNames.TodoComments,
|
||||
CommandNames.Indentation,
|
||||
CommandNames.DocCommentTemplate,
|
||||
CommandNames.CompilerOptionsDiagnosticsFull,
|
||||
CommandNames.NameOrDottedNameSpan,
|
||||
CommandNames.BreakpointStatement,
|
||||
CommandNames.CompilerOptionsForInferredProjects,
|
||||
CommandNames.GetCodeFixes,
|
||||
CommandNames.GetCodeFixesFull,
|
||||
CommandNames.GetSupportedCodeFixes,
|
||||
CommandNames.GetApplicableRefactors,
|
||||
CommandNames.GetRefactorCodeActions,
|
||||
CommandNames.GetRefactorCodeActionsFull,
|
||||
];
|
||||
|
||||
it("should not throw when commands are executed with invalid arguments", () => {
|
||||
let i = 0;
|
||||
for (const name in CommandNames) {
|
||||
if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) {
|
||||
continue;
|
||||
}
|
||||
for (const name of allCommandNames) {
|
||||
const req: protocol.Request = {
|
||||
command: name,
|
||||
seq: i,
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
* Declaration module describing the TypeScript Server protocol
|
||||
*/
|
||||
namespace ts.server.protocol {
|
||||
export enum CommandTypes {
|
||||
// NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`.
|
||||
export const enum CommandTypes {
|
||||
Brace = "brace",
|
||||
/* @internal */
|
||||
BraceFull = "brace-full",
|
||||
|
|
Loading…
Reference in a new issue