Skip to content

Commit

Permalink
test(uri): add an e2e test for uri
Browse files Browse the repository at this point in the history
  • Loading branch information
tatchi committed Jul 5, 2022
1 parent c73f87d commit 1e966c0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions ocaml-lsp-server/test/e2e/__tests__/uri.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import outdent from "outdent";
import * as rpc from "vscode-jsonrpc/node";
import * as LanguageServer from "../src/LanguageServer";
import * as Protocol from "vscode-languageserver-protocol";
import * as Types from "vscode-languageserver-types";
import { URI } from "vscode-uri";

describe("uri", () => {
let languageServer: rpc.MessageConnection;
const uri = URI.file("src/néw/Mödel + Other Thîngß/test.ml").toString();

function openDocument(source: string) {
languageServer.sendNotification(
Protocol.DidOpenTextDocumentNotification.type,
{
textDocument: Types.TextDocumentItem.create(uri, "ocaml", 0, source),
},
);
}

beforeEach(async () => {
languageServer = await LanguageServer.startAndInitialize();
});

afterEach(async () => {
await LanguageServer.exit(languageServer);
});

it("handles uri with special characters", async () => {
let receivedDiganostics: Promise<Protocol.PublishDiagnosticsParams> =
new Promise((resolve, _reject) =>
languageServer.onNotification(
Protocol.PublishDiagnosticsNotification.type,
(params) => {
resolve(params);
},
),
);
openDocument(outdent`
let () =
let x = 123 in
()
`);
const params = await receivedDiganostics;

expect(params.uri).toBe(uri);
});
});

0 comments on commit 1e966c0

Please sign in to comment.