Skip to content

Commit d7af1bc

Browse files
committed
test: can show documents
1 parent 7bede25 commit d7af1bc

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

test/adapters/show-document-adapter.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { TextEditor } from "atom"
12
import * as sinon from "sinon"
23
import { expect } from "chai"
4+
import { join, dirname } from "path"
5+
import Convert from "../../lib/convert"
36
import * as ShowDocumentAdapter from "../../lib/adapters/show-document-adapter"
4-
import { LanguageClientConnection } from "../../lib/languageclient"
7+
import { LanguageClientConnection, ShowDocumentParams } from "../../lib/languageclient"
58
import { createSpyConnection } from "../helpers"
69

710
describe("ShowDocumentAdapter", () => {
@@ -34,4 +37,33 @@ describe("ShowDocumentAdapter", () => {
3437
expect(typeof spyArgs[1]).to.equal("function")
3538
})
3639
})
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+
})
3769
})

test/fixtures/hello.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
atom.notifications.addSuccess("Hello World")

0 commit comments

Comments
 (0)