|
| 1 | +import { TextEditor } from "atom" |
1 | 2 | import * as sinon from "sinon"
|
2 | 3 | import { expect } from "chai"
|
| 4 | +import { join, dirname } from "path" |
| 5 | +import Convert from "../../lib/convert" |
3 | 6 | import * as ShowDocumentAdapter from "../../lib/adapters/show-document-adapter"
|
4 |
| -import { LanguageClientConnection } from "../../lib/languageclient" |
| 7 | +import { LanguageClientConnection, ShowDocumentParams } from "../../lib/languageclient" |
5 | 8 | import { createSpyConnection } from "../helpers"
|
6 | 9 |
|
7 | 10 | describe("ShowDocumentAdapter", () => {
|
@@ -34,4 +37,33 @@ describe("ShowDocumentAdapter", () => {
|
34 | 37 | expect(typeof spyArgs[1]).to.equal("function")
|
35 | 38 | })
|
36 | 39 | })
|
| 40 | + describe("can show documents", () => { |
| 41 | + describe("shows the document inside Atom", async () => { |
| 42 | + const helloPath = join(dirname(__dirname), "fixtures", "hello.js") |
| 43 | + const helloURI = Convert.pathToUri(helloPath) |
| 44 | + |
| 45 | + beforeEach(() => { |
| 46 | + atom.workspace.getTextEditors().forEach((ed) => { |
| 47 | + // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 48 | + //@ts-ignore |
| 49 | + ed.destroy() |
| 50 | + }) |
| 51 | + }) |
| 52 | + |
| 53 | + it("shows the document inside Atom for the given URI", async () => { |
| 54 | + const params: ShowDocumentParams = { |
| 55 | + uri: helloURI, |
| 56 | + } |
| 57 | + |
| 58 | + const { success } = await ShowDocumentAdapter.showDocument(params) |
| 59 | + expect(success).to.be.true |
| 60 | + |
| 61 | + const editor = atom.workspace.getTextEditors()[0] |
| 62 | + expect(editor instanceof TextEditor).to.be.true |
| 63 | + |
| 64 | + expect(editor!.getPath()).includes(helloPath) |
| 65 | + expect(editor!.getText()).includes(`atom.notifications.addSuccess("Hello World")`) |
| 66 | + }) |
| 67 | + }) |
| 68 | + }) |
37 | 69 | })
|
0 commit comments