Skip to content

Commit

Permalink
test: add FakeAutoLanguageClient
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 6, 2021
1 parent cc97ef4 commit 1f33ac0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as sinon from "sinon"
import * as rpc from "vscode-jsonrpc"
import { TextEditor } from "atom"
import AutoLanguageClient from "../lib/auto-languageclient"
import { LanguageClientConnection } from "../lib/languageclient"
import { LanguageServerProcess } from "../lib/server-manager"
import { spawn } from "spawk"
import { ChildProcess } from "child_process"

Expand Down Expand Up @@ -41,3 +44,23 @@ export function createFakeLanguageServerProcess(): LanguageServerProcess {
return require("child_process").spawn("ls") as ChildProcess
}

/* eslint-disable class-methods-use-this */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

export class FakeAutoLanguageClient extends AutoLanguageClient {
public getLanguageName() {
return "JavaScript"
}
public getServerName() {
return "JavaScriptTest"
}
public getGrammarScopes() {
return ["source.javascript"]
}
public startServerProcess() {
return createFakeLanguageServerProcess()
}
public preInitialization(connection: LanguageClientConnection) {
connection.initialize = sinon.stub().returns(Promise.resolve({ capabilities: {} }))
}
}

0 comments on commit 1f33ac0

Please sign in to comment.